/* ============================================================
   永定区学生信息管理系统 · theme.css
   视觉规范对齐「学生资助管理系统」(zizhu.cclearn.cn)
   ------------------------------------------------------------
   设计 token 直接取自 funding_system/public/assets/style.css：
   渐变蓝主色 / 青绿点缀 / Soft-UI 柔和风 / 深蓝侧边栏
   同时遵守移动端 5 铁律：
     · 输入框 font-size >= 16px（防 iOS 自动放大）
     · 按钮/可点热区 min-height >= 44px
     · position:fixed 的子项 min-width:0（防挤爆）
     · 冻结列 translateZ(0)（防层叠闪烁）
     · 不使用内联 font-size
   ============================================================ */

/* ---------- tokens ---------- */
:root {
  /* 主色：渐变蓝（与资助系统同源） */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #e8f1fe;
  --primary-grad: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
  --primary-grad-h: linear-gradient(135deg, #1d4ed8 0%, #0284c7 100%);
  --accent: #0ea5e9;
  --accent-soft: #e6f5fd;
  --cyan: #06b6d4;
  --danger: #dc3545;
  --danger-soft: #fdecec;
  --warn: #f59e0b;
  --warn-soft: #fff8e6;
  --success: #10b981;
  --success-soft: #e6f7f1;

  --text: #1e293b;
  --text-2: #64748b;
  --border: #dfe7f3;
  --layer-2: #f5f8fd;
  --layer-3: #eaf1fb;
  --card: #ffffff;
  --page-bg: #f4f8fd;
  --tint: #eff6ff;

  /* 侧边栏：深蓝 */
  --sidebar: #0b2b45;
  --sidebar-2: #123a5c;
  --sidebar-text: #b6cde4;
  --sidebar-text-hi: #ffffff;
  --sidebar-group: #6f96b8;
  --sidebar-hover: rgba(255, 255, 255, .1);
  --sidebar-line: rgba(255, 255, 255, .09);

  --radius-lg: 16px;
  --radius: 10px;
  --radius-sm: 8px;

  --sh-card: 0 2px 12px rgba(15, 40, 80, .05);
  --sh-card-h: 0 8px 24px rgba(37, 99, 235, .14);
  --sh-btn: 0 2px 6px rgba(37, 99, 235, .22);
  --sh-btn-h: 0 4px 12px rgba(37, 99, 235, .32);
  --sh-focus: 0 0 0 3px rgba(37, 99, 235, .16);

  --font-cn: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-en: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* 流体尺寸：Windows 200% 缩放 / 手机竖屏都不挤爆 */
  --fs-base:  clamp(14px, 13.2px + 0.12vw, 15px);
  --pad-card: clamp(16px, 12px + 0.9vw, 24px);
  --gap-card: clamp(12px, 9px + 0.7vw, 20px);
  --pad-page: clamp(16px, 8px + 1.6vw, 32px);
  --h-btn:    clamp(44px, 40px + 0.5vw, 46px);
  --h-input:  clamp(44px, 40px + 0.5vw, 46px);
  --sidebar-w: 232px;
  --topbar-h: 60px;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--text);
  font: var(--fs-base)/1.6 var(--font-en), var(--font-cn);
  background:
    radial-gradient(1100px 520px at 82% -8%, rgba(37, 99, 235, .10), transparent 62%),
    radial-gradient(760px 420px at 4% 102%, rgba(14, 165, 233, .08), transparent 58%),
    var(--page-bg);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}
a { color: var(--primary-dark); }
.muted { color: var(--text-2); }
.nowrap { white-space: nowrap; }

/* ============================================================
   登录页
   ============================================================ */
body.auth-page {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  min-height: 100vh; min-height: 100dvh; padding: 24px 16px;
}
.login-box {
  width: 100%; max-width: 400px;
  background: rgba(255, 255, 255, .95); backdrop-filter: blur(6px);
  border: 1px solid rgba(226, 232, 240, .9); border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(15, 23, 42, .07); padding: 34px 30px 26px;
}
.login-logo {
  width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 18px;
  background: var(--primary-grad);
  box-shadow: 0 6px 18px rgba(37, 99, 235, .35);
  display: flex; align-items: center; justify-content: center; font-size: 30px;
}
.login-title { margin: 0 0 4px; font-size: 21px; font-weight: 600; text-align: center; }
.login-sub { margin: 0 0 22px; text-align: center; color: var(--text-2); font-size: 13px; }
.login-foot {
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
  text-align: center; font-size: 12px; color: var(--text-2); line-height: 1.7;
}
.login-foot a { color: var(--primary-dark); text-decoration: none; }
.login-foot a:hover { text-decoration: underline; }

/* ============================================================
   应用外壳
   ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  /* 侧栏用 sticky + 100vh，页面比一屏高时下方会露出页面底色。
     用一层左侧等宽渐变垫底，保证滚动到底部时侧栏背景不断裂。 */
  background: linear-gradient(90deg,
              var(--sidebar) 0,
              var(--sidebar) calc(var(--sidebar-w) - 1px),
              transparent var(--sidebar-w));
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  min-width: 0;                       /* 铁律：fixed/sticky 子项不得撑破 */
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.logo-area {
  padding: 4px 10px 18px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--sidebar-line);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.logo-area .logo-mark {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 12px;
  background: var(--primary-grad);
  box-shadow: 0 4px 12px rgba(37, 99, 235, .4);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
}
.logo-area h2 {
  margin: 0;
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--sidebar-text-hi);
  line-height: 1.35;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-menu {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.nav-group-title {
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--sidebar-group);
  padding: 14px 12px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;                    /* 铁律：热区 >=44px */
  padding: 0 12px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  min-width: 0;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.nav-item .icon {
  font-size: 16px;
  width: 20px;
  flex: 0 0 20px;
  text-align: center;
  line-height: 1;
  opacity: 1;
  color: inherit;
  /* 显式指定彩色 emoji 字体，避免部分环境回退成单色轮廓 */
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji",
               "Segoe UI Symbol", "EmojiOne Color", sans-serif;
  font-variant-emoji: emoji;
}
.nav-item .nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-hi); }
.nav-item.active {
  background: var(--primary-grad);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, .38);
}

/* 侧边栏底部用户区 */
.user-info-sidebar {
  margin-top: 12px;
  padding: 14px 4px 2px;
  border-top: 1px solid var(--sidebar-line);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.user-avatar {
  width: 38px; height: 38px; flex: 0 0 38px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.user-details { flex: 1; min-width: 0; }
.user-name {
  font-weight: 600; font-size: 13px; color: var(--sidebar-text-hi);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role { font-size: 11px; color: var(--sidebar-group); margin-top: 2px; }

.sidebar-buttons {
  display: flex;
  gap: 6px;
  width: 100%;
  min-width: 0;
  margin-top: 10px;
}
.sidebar-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  display: inline-flex;
  flex-direction: column;              /* emoji 与文字上下排，66px 足够放下两字 */
  align-items: center; justify-content: center;
  gap: 1px;
  text-align: center;
  padding: 4px 2px;
  background: rgba(255, 255, 255, .1);
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  line-height: 1.15;
  font-size: 11px;
  white-space: nowrap;
  transition: background .18s ease, color .18s ease;
}
/* 侧栏 232px，三个按钮平分后每个约 66px，横排会把「修改」裁成一个字 */
.sidebar-btn .btn-text {
  display: block;
  flex: 0 0 auto;
  letter-spacing: 0;
}
.sidebar-btn:hover { background: rgba(255, 255, 255, .2); color: #fff; }

/* ---------- 主内容区 ---------- */
.main-content {
  flex: 1 1 auto;
  min-width: 0;
  padding: var(--pad-page);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: var(--gap-card);
  flex-shrink: 0;
}
.page-title h1 {
  margin: 0;
  font-size: clamp(19px, 16px + 0.7vw, 24px);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.2px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.subtitle {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--tint);
  border: 1px solid #dbeafe;
  border-radius: 999px;
  padding: 3px 11px;
}

/* ============================================================
   卡片 / 按钮
   ============================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--sh-card);
  padding: var(--pad-card);
  min-width: 0;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--h-btn);
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--primary-grad);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--sh-btn);
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease,
              border-color .2s ease, color .2s ease;
}
.btn:hover {
  background: var(--primary-grad-h);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: var(--sh-btn-h);
}
.btn:active { transform: scale(.98); }
.btn:disabled,
.btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* 主按钮（渐变蓝） */
.btn-primary { background: var(--primary-grad); color: #fff; }
.btn-primary:hover { background: var(--primary-grad-h); }

/* 次要按钮：淡蓝底 + 蓝字 */
.btn-secondary,
.btn-outline {
  background: var(--primary-soft);
  border-color: #c7dcfb;
  color: var(--primary-dark);
  box-shadow: none;
}
.btn-secondary:hover,
.btn-outline:hover {
  background: #d8e8fd;
  border-color: #a9c9f7;
  color: var(--primary-dark);
  box-shadow: none;
}

/* 强调（青绿渐变）：导出 */
.btn-export,
.btn-import {
  background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
  color: #fff;
}
.btn-export:hover,
.btn-import:hover {
  background: linear-gradient(135deg, #0284c7 0%, #0891b2 100%);
  color: #fff;
}

/* 危险：淡红底 + 红字 */
.btn-danger {
  background: var(--danger-soft);
  border-color: #f7d2d6;
  color: var(--danger);
  box-shadow: none;
}
.btn-danger:hover {
  background: #fbdadf;
  border-color: #f2bcc4;
  color: #b02a37;
  box-shadow: none;
}

/* 警告：淡黄底 + 棕字 */
.btn-warning,
.btn-template {
  background: var(--warn-soft);
  border-color: #f3e2bd;
  color: #8a6314;
  box-shadow: none;
}
.btn-warning:hover,
.btn-template:hover {
  background: #fdf0cf;
  border-color: #edd49b;
  color: #6f4f0f;
  box-shadow: none;
}

.btn-info { background: var(--accent-soft); border-color: #bfe6f7; color: #0b6c8a; box-shadow: none; }
.btn-info:hover { background: #d6eefb; color: #085a73; box-shadow: none; }

.btn.big { min-height: 48px; font-size: 16px; }
.btn.full { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }

/* ============================================================
   表单
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.field-label .req { color: var(--danger); margin-left: 2px; }

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-box .form { gap: 18px; }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="email"],
input:not([type]),
select,
textarea {
  width: 100%;
  min-height: var(--h-input);
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 16px;                    /* 铁律：>=16px 防 iOS 自动放大 */
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
textarea { padding: 10px 13px; min-height: 96px; line-height: 1.6; resize: vertical; }
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8.5 1.5 4h9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--sh-focus);
}
input:read-only,
input[readonly] {
  background: var(--layer-2);
  color: var(--text-2);
  cursor: not-allowed;
}
input::placeholder { color: #9aa9bd; }

/* 记住用户名等勾选项 */
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}
.check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
  flex: 0 0 18px;
}

/* ============================================================
   提示条
   ============================================================ */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: var(--gap-card);
  font-size: 14px;
  animation: fade-down .35s ease-out;
  word-break: break-word;
}
.flash.ok { background: var(--success-soft); color: #0b7c5e; border: 1px solid #bfe8d9; }
.flash.err { background: var(--danger-soft); color: #a33040; border: 1px solid #f6d3d8; }
.notice {
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--warn-soft);
  color: #8a6314;
  border: 1px solid #f3e2bd;
  font-size: 14px;
  margin-bottom: var(--gap-card);
}

/* 兼容旧类名（各页面原有的 alert / alert-success 等） */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: var(--gap-card); font-size: 14px; }
.alert-success { background: var(--success-soft); color: #0b7c5e; border: 1px solid #bfe8d9; }
.alert-error   { background: var(--danger-soft); color: #a33040; border: 1px solid #f6d3d8; }
.alert-warning { background: var(--warn-soft); color: #8a6314; border: 1px solid #f3e2bd; }

@keyframes fade-down {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fade-in .4s ease-out both; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   查询栏
   ============================================================ */
.quick-actions {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--sh-card);
  padding: 14px var(--pad-card);
  margin-bottom: var(--gap-card);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  flex-shrink: 0;
  min-width: 0;
}
.search-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
}
/* 查询栏：输入框按内容自适应、按钮保持原宽，整行放不下时整组换行 */
.search-form input,
.search-form select {
  width: auto;
  flex: 0 1 170px;
  min-width: 140px;
}
.search-form input[type="text"][name="search"] { flex: 1 1 230px; min-width: 190px; }
.search-form .btn { flex: 0 0 auto; }
/* 「查询 / 重置」保持在同一行，不被挤散 */
.search-actions { display: inline-flex; gap: 8px; flex: 0 0 auto; white-space: nowrap; }
.batch-actions { display: flex; gap: 8px; flex-wrap: wrap; min-width: 0; }
.btn-group-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }

/* ============================================================
   表格
   ============================================================ */
.table-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
/* 旧页面形态：.table-wrapper 直接包裹表格（statistics.php 的透视表）
   这类页面没有 .table-scroll-x 中间层，容器本身必须承担滚动职责，
   否则宽表会把整个页面顶出视口。保留原骨架的 overflow:auto + max-height。 */
.table-wrapper > div > .pivot-table,
.table-wrapper > .pivot-table {
  display: table;
}
.table-wrapper:has(> div > .pivot-table),
.table-wrapper:has(> .pivot-table) {
  display: block;
  overflow: auto;
  max-height: 60vh;
  min-width: 0;
  max-width: 100%;
  position: relative;
}
.table-scroll-x {
  overflow-x: auto;
  overflow-y: visible;
  flex: 1;
  min-width: 0;
}
.table-scroll-y {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

.data-table-container,
.table-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--sh-card);
  margin-top: var(--gap-card);
  overflow: auto;                     /* 必须保留：宽表在手机上靠它横向滚动 */
  min-width: 0;
  max-width: 100%;
}

.data-table {
  width: 100%;
  /* 不再固定 2200px：25 列的宽表由内容自己撑开，
     3~7 列的窄表（logs/archive）不会被无谓拉宽、逼出横向滚动。
     手机端仍有 .table-container 的 overflow:auto 兜底。 */
  min-width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.data-table th {
  background: var(--layer-2);
  padding: 12px 10px;
  text-align: left;
  font-weight: 600;
  color: var(--text-2);
  font-size: 12.5px;
  letter-spacing: .02em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
  transform: translateZ(0);            /* 铁律：冻结列/吸顶开启合成层，防闪烁 */
}
.data-table td {
  padding: 10px;
  border-bottom: 1px solid var(--layer-3);
  color: var(--text);
  white-space: nowrap;
  background: var(--card);
  transform: translateZ(0);
}
.data-table tbody tr:hover td { background: var(--tint); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tr.disabled-row td { background: var(--layer-2); color: #9aa9bd; }
.data-table tr.disabled-row:hover td { background: var(--layer-2); }

.data-table input[type="checkbox"] {
  width: 18px; height: 18px;
  min-height: 0; margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}
.empty-data {
  text-align: center;
  padding: 56px 16px !important;
  color: var(--text-2);
  font-size: 14px;
}

/* ============================================================
   分页
   ============================================================ */
.pagination {
  margin-top: var(--gap-card);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 12px 0 0;
  flex-shrink: 0;
}
.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  min-width: 40px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: all .18s ease;
}
.pagination a:hover {
  border-color: #c7dcfb;
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.pagination .current {
  background: var(--primary-grad);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--sh-btn);
}
.pagination .disabled { color: #b9c4d4; background: var(--layer-2); }
.page-size-select {
  min-height: 40px;
  width: auto;
  min-width: 108px;
  font-size: 13px;
  padding: 0 30px 0 10px;
}

/* ============================================================
   弹窗
   ============================================================ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(3px);
  justify-content: center;
  align-items: center;
  padding: 16px;
  z-index: 1000;
}
.modal-content {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(15, 23, 42, .22);
  width: 100%;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  min-width: 0;                        /* 铁律：fixed 子项 min-width:0 */
  animation: modal-in .25s ease-out both;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-large { max-width: 1000px; }
.modal-medium { max-width: 600px; }
.modal-header {
  padding: 16px var(--pad-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 2;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  min-width: 0;
}
.modal-body { padding: var(--pad-card); }
.modal-footer {
  padding: 14px var(--pad-card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  background: var(--card);
}
.close {
  width: 40px; height: 40px;
  flex: 0 0 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none;
  background: var(--layer-2);
  border-radius: var(--radius-sm);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-2);
  transition: all .18s ease;
}
.close:hover { background: var(--danger-soft); color: var(--danger); }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.form-group { min-width: 0; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 13px;
  color: var(--text-2);
}
.form-group label .required { color: var(--danger); margin-left: 3px; }
.form-group input,
.form-group select { font-size: 16px; }
.form-group input:focus,
.form-group select:focus { outline: none; border-color: var(--primary); box-shadow: var(--sh-focus); }

datalist { display: none; }

/* ============================================================
   统计卡片 / 日志
   ============================================================ */
.card-grid { display: flex; gap: var(--gap-card); margin-bottom: var(--gap-card); flex-wrap: wrap; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--sh-card);
  padding: var(--pad-card);
  flex: 1;
  min-width: 180px;
  text-align: center;
}
.stat-number { font-size: clamp(24px, 20px + 1.4vw, 32px); font-weight: 700; color: var(--primary); }

.log-detail {
  background: var(--layer-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 8px;
  font-size: 12px;
  max-height: 300px;
  overflow-y: auto;
}
.log-detail pre {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  margin: 0;
}


/* ============================================================
   共用业务组件（statistics / users / history / rules / logs /
   import / archive / help 等页面共用）
   2026-10-17 新增：这些页面原来的内联样式里硬编码了旧的绿色主题
   与老式表格，统一收到这里，保证全站一套视觉。
   ============================================================ */

/* ---------- 内容面板（替代各页的 .content-panel/.stats-container/.archive-container） ---------- */
.content-panel,
.stats-container,
.archive-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--sh-card);
  padding: var(--pad-card);
  margin-top: var(--gap-card);
  min-width: 0;
}

.stats-title,
.panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* ---------- 工具栏 / 操作条 ---------- */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: var(--gap-card);
}

/* ---------- 分页（所有列表页统一） ---------- */
.pagination a,
.pagination span:not(.current) {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-weight: 500;
}
.pagination a:hover {
  border-color: #c7dcfb;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

/* ---------- 徽章 ---------- */
.badge,
.badge-admin,
.badge-school,
.badge-town {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.badge-admin {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #f6d3d8;
}
.badge-school {
  background: var(--success-soft);
  color: #0b7c5e;
  border: 1px solid #bfe8d9;
}
.badge-town {
  background: var(--warn-soft);
  color: #8a6314;
  border: 1px solid #f3e2bd;
}
.badge-info {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border: 1px solid #c7dcfb;
}

/* ---------- 信息卡 / 提示框 ---------- */
.info-card {
  background: var(--layer-2);
  border: 1px solid var(--border);
  padding: var(--pad-card);
  border-radius: var(--radius);
  margin-bottom: var(--gap-card);
}
.warning-box {
  background: var(--warn-soft);
  border: 1px solid #f3e2bd;
  border-left: 4px solid var(--warn);
  color: #8a6314;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: var(--gap-card);
  line-height: 1.7;
}

/* ---------- 空态 ---------- */
.empty-row td,
.empty-data {
  text-align: center;
  color: var(--text-2);
  padding: 48px 16px !important;
}

/* 表格单元格内的长文本换行（日志详情等） */
.cell-wrap { white-space: normal; word-break: break-word; }

/* ---------- 表单控件别名 / 页面专用（对齐后统一） ---------- */
.form-control {
  width: 100%;
  min-height: var(--h-input);
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  transition: border-color .18s ease, box-shadow .18s ease;
}
select.form-control {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8.5 1.5 4h9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--sh-focus);
}

/* 已有 data-table 之外的第二套表格（归档页） */
.archive-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.archive-table th {
  background: var(--layer-2);
  color: var(--text-2);
  font-weight: 600;
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.archive-table td {
  padding: 10px;
  border-bottom: 1px solid var(--layer-3);
  color: var(--text);
}
.archive-table tbody tr:hover td { background: var(--tint); }

/* 归档页的行动按钮（小号） */
.btn-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #f7d2d6;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.btn-delete:hover { background: #fbdadf; color: #b02a37; }
.btn.btn-archive {
  background: var(--danger-soft);
  border-color: #f7d2d6;
  color: var(--danger);
  box-shadow: none;
}
.btn.btn-archive:hover { background: #fbdadf; color: #b02a37; box-shadow: none; }

/* 归档表单区块 */
.archive-form {
  background: var(--layer-2);
  border: 1px solid var(--border);
  padding: var(--pad-card);
  border-radius: var(--radius);
  margin-top: var(--gap-card);
}

/* 改密页独立卡片（无侧栏） */
.password-box {
  max-width: 460px;
  margin: 9vh auto 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(15, 23, 42, .07);
  padding: 30px;
}
.password-box h2 {
  margin: 0 0 20px;
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
}

/* 导入页的警告滚动区、结果区 */
.warning-scroll {
  max-height: 220px;
  overflow-y: auto;
  background: var(--warn-soft);
  border: 1px solid #f3e2bd;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-top: 8px;
}
.alert-success { max-height: 360px; overflow-y: auto; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1100px) {
  :root { --sidebar-w: 76px; }
  .logo-area { justify-content: center; padding: 4px 0 14px; }
  .logo-area h2 { display: none; }
  .logo-area .logo-mark { margin: 0 auto; }
  .nav-item { justify-content: center; padding: 0 8px; gap: 0; }
  .nav-item .nav-label { display: none; }
  .nav-group-title { display: none; }
  .user-details { display: none; }
  .user-info-sidebar { justify-content: center; }
  /* 窄侧边栏时按钮改为纵向堆叠的图标方块，隐藏文字避免被压扁溢出 */
  .sidebar-buttons { flex-direction: column; gap: 6px; }
  .sidebar-btn {
    width: 100%;
    min-height: 40px;
    padding: 0;
    font-size: 14px;
  }
  .sidebar-btn .btn-text { display: none; }
}

@media (max-width: 767px) {
  :root { --sidebar-w: 64px; --pad-page: 14px; }
  .main-content { padding: 14px 12px; }
  .nav-item { min-height: 44px; }
  .quick-actions { padding: 12px; }
  .search-form input,
  .search-form select { min-width: 0; width: 100%; flex: 1 1 100%; }
  .btn-group-right { width: 100%; }
  .btn-group-right .btn { flex: 1 1 auto; padding: 0 12px; font-size: 13px; }
  .form-row { grid-template-columns: 1fr; }
  .modal-large, .modal-medium { max-width: 100%; }
  .modal { padding: 8px; align-items: flex-end; }
  .modal-content { max-height: 92vh; }
}

/* ============================================================
   会话超时提示（session-guard.js）
   ------------------------------------------------------------
   超时前 60 秒弹出，带倒计时；点「继续使用」续期。
   样式与全站一致，移动端自适应。
   ============================================================ */
.idle-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(2px);
  padding: 16px;
}
.idle-modal.show { display: flex; }

.idle-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(15, 23, 42, .28);
  padding: 28px 26px 22px;
  width: 100%;
  max-width: 400px;
  min-width: 0;                       /* 铁律：fixed 子项 min-width:0 */
  text-align: center;
  animation: modal-in .22s ease-out both;
}
.idle-icon { font-size: 34px; line-height: 1; margin-bottom: 10px; }
.idle-card h3 {
  margin: 0 0 10px;
  font-size: 17px;
  color: var(--text);
  font-weight: 700;
}
.idle-card p {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-2);
}
.idle-card .idle-remain {
  color: var(--danger);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}
.idle-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.idle-actions .btn { min-width: 118px; min-height: var(--h-btn); }

@media (max-width: 480px) {
  .idle-card { padding: 22px 18px 18px; }
  .idle-actions .btn { min-width: 0; flex: 1 1 0; }
}
