/* ============================================================
   皙昂大学 AI 校园一卡通 · 全局设计系统（Design System Base）
   ------------------------------------------------------------
   本文件是三端（学生端 / 商家端 / 学校端）共享的视觉基座，
   由 app.css（移动端）与 admin.css（管理端）在其之前引入。

   设计基线取自 stu / esign：
     · 点阵 + 竖向渐变底色
     · 紫蓝主色 + 暖橙辅助色的双色系统
     · 大圆角、厚投影、卡片化容器
     · 移动优先，桌面渐进增强

   分区：
     01 Token          设计变量（颜色 / 字号 / 间距 / 圆角 / 阴影 / 动效）
     02 Reset          基础重置
     03 Backdrop       页面底色与纹理
     04 Typography     排版基线
     05 Surface        容器：panel / box / card
     06 Section        小节标题与分组
     07 Button         按钮体系
     08 Field          表单控件
     09 Table          表格
     10 Status         徽章 / 药丸 / 状态标签
     11 Flash          提示条
     12 Empty          空状态
     13 Utilities      工具类
   ============================================================ */

/* ============================================================
   01 · Token
   ============================================================ */
:root {
  /* ---- 品牌色 ---- */
  --brand:        #3b5bdb;
  --brand-2:      #4f6ef7;
  --brand-3:      #6d86f5;
  --brand-ink:    #24307d;   /* 深色文字用 */
  --brand-deep:   #1b2470;
  --brand-l:      rgba(59, 91, 219, .10);
  --brand-l-2:    rgba(59, 91, 219, .06);
  --brand-bd:     rgba(59, 91, 219, .24);
  --brand-glow:   rgba(59, 91, 219, .32);

  /* 品牌渐变（统一出口，避免各处重复拼渐变） */
  --grad-brand:   linear-gradient(135deg, var(--brand-2) 0%, var(--brand) 100%);
  --grad-brand-s: linear-gradient(160deg, #4f6ef7 0%, #3b5bdb 100%);

  /* ---- 功能色 ---- */
  --danger:       #f4364e;
  --danger-2:     #ff8f5e;
  --danger-l:     #fdecea;
  --danger-bd:    #f7cdc8;
  --danger-ink:   #b03024;

  --success:      #16a34a;
  --success-2:    #16b364;
  --success-l:    #e8f7ef;
  --success-bd:   #bfe5d1;
  --success-ink:  #0a6e3d;

  --warn:         #ff9d2e;
  --warn-l:       #fdf3e4;
  --warn-bd:      #f6dcb4;
  --warn-ink:     #b9770e;

  --info:         #2f86eb;
  --info-l:       #e9f2fe;
  --info-bd:      #c2dbf8;
  --info-ink:     #1d64b8;

  /* ---- 中性色 ---- */
  --text:         #1a1a2e;
  --text-2:       #4e558f;
  --text-3:       #9ba1cf;
  --text-4:       #8599a6;

  --bg:           #f0f4ff;
  --bg-2:         #e7eeff;
  --surface:      #ffffff;
  --surface-2:    #f8faff;
  --surface-3:    #f1f5fc;

  --border:       #e8ecfb;
  --border-2:     #dde4f6;
  --border-3:     #cfd9f2;

  /* ---- 圆角（统一四档，别再随手写 8/10/12/14/16） ---- */
  --r-xs:   8px;
  --r-sm:   10px;
  --r-md:   14px;
  --r-lg:   18px;
  --r-xl:   22px;
  --r-pill: 999px;

  /* ---- 间距（4 的倍数栅格） ---- */
  --s-1:  4px;
  --s-2:  8px;
  --s-3:  12px;
  --s-4:  16px;
  --s-5:  20px;
  --s-6:  24px;
  --s-7:  32px;
  --s-8:  40px;

  /* ---- 阴影（三档 + 品牌发光） ---- */
  --sh-1: 0 1px 2px rgba(30, 50, 120, .06), 0 2px 6px rgba(30, 50, 120, .05);
  --sh-2: 0 4px 12px rgba(30, 50, 120, .08), 0 2px 4px rgba(30, 50, 120, .04);
  --sh-3: 0 14px 36px rgba(30, 50, 120, .14), 0 3px 10px rgba(30, 50, 120, .07);
  --sh-brand: 0 6px 18px var(--brand-glow);

  /* ---- 字号（行高成对定义，避免各文件自行组合） ---- */
  --fs-xs:   11.5px;  --lh-xs:   1.5;
  --fs-sm:   12.5px;  --lh-sm:   1.55;
  --fs-base: 14px;    --lh-base: 1.62;
  --fs-md:   15px;    --lh-md:   1.62;
  --fs-lg:   16.5px;  --lh-lg:   1.5;
  --fs-xl:   19px;    --lh-xl:   1.42;
  --fs-2xl:  23px;    --lh-2xl:  1.34;
  --fs-3xl:  27px;    --lh-3xl:  1.28;

  /* ---- 动效 ---- */
  --ease:      cubic-bezier(.22, .68, .36, 1);
  --ease-back: cubic-bezier(.22, 1.36, .36, 1);
  --t-fast:    .14s;
  --t-base:    .22s;

  /* ---- 布局 ---- */
  --maxw:      460px;      /* 移动端内容最大宽 */
  --maxw-wide: 1280px;     /* 管理端内容最大宽 */
  --sidebar-w:  244px;
  --topbar-h:   58px;
}

/* ============================================================
   01b · 向后兼容别名
   ------------------------------------------------------------
   历史代码里用的是无连字符的旧命名（--brand2 / --text2 …）。
   统一在此做别名映射：新代码请一律用上面的 kebab-case 命名，
   这样调一次色板即可全站生效，不必逐处替换旧变量名。
   ============================================================ */
:root {
  --brand2:     var(--brand-2);
  --danger2:    var(--danger-2);
  --success2:   var(--success-2);
  --text2:      var(--text-2);
  --text3:      var(--text-3);
  --text4:      var(--text-4);
}

/* ============================================================
   02 · Reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei",
               "Helvetica Neue", Arial, sans-serif;
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  min-height: 100dvh;
}

a { color: var(--brand); text-decoration: none; transition: color var(--t-fast) var(--ease); }
a:hover { color: var(--brand-2); }

b, strong { font-weight: 700; }
img { max-width: 100%; display: block; }

h1, h2, h3, h4, h5, h6 { font-weight: 800; line-height: 1.35; letter-spacing: -.01em; }

p { line-height: var(--lh-base); }

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

button { cursor: pointer; border: 0; background: none; }

/* 表单容器重置：部分内核会给 <form> 套 UA 默认浅底/边框，
   在这里一次性抹平，避免每个页面单独处理 */
form { background: transparent; border: 0; padding: 0; margin: 0; }

ul, ol { margin: 0; padding: 0; list-style: none; }

hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-5) 0; }

/* 统一焦点环：键盘可达性 + 视觉一致 */
:focus-visible {
  outline: 2px solid var(--brand-3);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* 数字统一等宽，表格与金额不再跳动 */
.num, .mono, table td, .amt, .amount {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ============================================================
   03 · Backdrop —— 点阵 + 竖向渐变（与 stu / esign 一致）
   ============================================================ */
body {
  background:
    radial-gradient(circle, #d5e5f7 1.2px, transparent 1.2px) 0 0 / 20px 20px,
    linear-gradient(180deg, #fbfcff 0%, var(--bg) 100%);
  background-attachment: fixed;
  color: var(--text);
}

/* ============================================================
   04 · Typography
   ============================================================ */
.page-title {
  font-size: var(--fs-2xl);
  font-weight: 900;
  letter-spacing: -.4px;
  color: var(--text);
}
.page-sub {
  font-size: var(--fs-sm);
  color: var(--text-3);
  margin-top: 2px;
}

.muted  { color: var(--text-3); }
.dim    { color: var(--text-2); }
.strong { font-weight: 800; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }

/* 段落级说明文字 */
.note {
  font-size: var(--fs-sm);
  color: var(--text-3);
  line-height: 1.75;
}

/* ============================================================
   05 · Surface —— 容器
   ============================================================ */

/* 移动端面板：三端通用，卡片化主容器 */
.panel {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  margin: var(--s-3) var(--s-4);
  overflow: hidden;
}
.panel-pad { padding: var(--s-4); }

/* 面板标题：左侧带品牌色竖条，视觉锚点更明确 */
.panel-title {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-4) var(--s-3);
  font-size: var(--fs-md);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.2px;
}
.panel-title::before {
  content: "";
  width: 3px;
  height: 15px;
  border-radius: var(--r-pill);
  background: var(--grad-brand);
  flex: none;
}
.panel-title > span,
.panel-title > b { font-weight: 800; }

.panel-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-4) var(--s-3);
}
.panel-more {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--brand);
  flex: none;
}
.panel-more:active { opacity: .6; }

/* 管理端容器：白底 + 细边框，比移动端更"工具感" */
.box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.box + .box { margin-top: var(--s-4); }

/* 迷你容器：表格内的次级块 */
.mini {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.mini-fold summary {
  cursor: pointer;
  padding: 10px var(--s-4);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text-2);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.mini-fold summary::-webkit-details-marker { display: none; }

/* 独立卡片（移动端） */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  padding: var(--s-5);
}

/* 卡片入场：统一节奏，全站一致的"落位感" */
@keyframes wbRise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.rise { animation: wbRise var(--t-base) var(--ease) both; }

/* ============================================================
   06 · Section —— 分组标题
   ============================================================ */
.sec-title {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin: var(--s-6) var(--s-4) var(--s-3);
  font-size: var(--fs-sm);
  font-weight: 800;
  color: var(--text-3);
  letter-spacing: .6px;
}
.sec-title::before {
  content: "";
  width: 14px;
  height: 2px;
  border-radius: var(--r-pill);
  background: var(--brand-3);
  flex: none;
}

/* 两栏 / 三栏布局 */
.two   { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-3); }
.split { display: flex; gap: var(--s-3); }
.grow  { flex: 1; min-width: 0; }

/* ============================================================
   07 · Button
   ============================================================ */
.btn,
.btn-primary,
.btn-plain,
.btn-danger,
.btn-mini,
.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  border-radius: var(--r-pill);
  transition: transform var(--t-fast) var(--ease-back),
              box-shadow var(--t-fast) var(--ease),
              opacity var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
.btn:active,
.btn-primary:active,
.btn-plain:active,
.btn-danger:active { transform: scale(.96); opacity: .92; }

/* 主按钮：品牌渐变 + 品牌投影 */
.btn-primary {
  background: var(--grad-brand);
  color: #fff;
  font-size: var(--fs-md);
  padding: 13px var(--s-6);
  box-shadow: var(--sh-brand);
  letter-spacing: .5px;
}

/* 次按钮：浅底 + 品牌字 */
.btn-plain {
  background: var(--brand-l);
  color: var(--brand);
  font-size: var(--fs-base);
  padding: 12px var(--s-5);
  border: 1px solid var(--brand-bd);
}

/* 危险按钮 */
.btn-danger {
  background: var(--danger-l);
  color: var(--danger-ink);
  font-size: var(--fs-base);
  padding: 12px var(--s-5);
  border: 1px solid var(--danger-bd);
}

/* 尺寸变体 */
.btn-mini { font-size: var(--fs-sm); padding: 7px 14px; }
.btn-sm   { font-size: var(--fs-sm); padding: 9px 16px; }

/* 按钮成组：撑满一行，等宽 */
.btn-row {
  display: flex;
  gap: var(--s-3);
  margin: var(--s-4);
}
.btn-row > .btn,
.btn-row > .btn-primary,
.btn-row > .btn-plain,
.btn-row > .btn-danger { flex: 1; }

/* 禁用态统一 */
.btn[disabled],
.btn-primary[disabled],
.btn-plain[disabled],
button:disabled {
  opacity: .5;
  pointer-events: none;
  box-shadow: none;
}

/* ============================================================
   08 · Field —— 表单
   ============================================================ */
.field { margin-bottom: var(--s-4); position: relative; }

.field .lbl,
.lbl {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 6px;
  letter-spacing: .2px;
}

.field input,
.field select,
.field textarea,
.form input,
.form select,
.form textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-md);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.field input:focus,
.field select:focus,
.field textarea:focus,
.form input:focus,
.form select:focus,
.form textarea:focus {
  border-color: var(--brand-3);
  box-shadow: 0 0 0 3px var(--brand-l);
}
.field input::placeholder,
.form input::placeholder { color: #a9b4d4; }

/* 选中态下拉 */
.field select,
.form select {
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

textarea { resize: vertical; min-height: 88px; line-height: 1.7; }

/* 表单栅格：移动端单列，桌面两列 */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--s-3) var(--s-4);
}
.form-grid > .field { margin-bottom: 0; }
.form-grid { margin-bottom: var(--s-4); }

/* ============================================================
   09 · Table
   ============================================================ */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-base);
}
.tbl th {
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: .5px;
  color: var(--text-3);
  padding: 10px var(--s-3);
  background: var(--surface-3);
  border-bottom: 1px solid var(--border-2);
  white-space: nowrap;
}
.tbl td {
  padding: 11px var(--s-3);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.tbl tbody tr { transition: background var(--t-fast) var(--ease); }
.tbl tbody tr:nth-child(even) { background: rgba(241, 245, 252, .5); }
.tbl tbody tr:hover { background: var(--brand-l-2); }
.tbl tbody tr:last-child td { border-bottom: 0; }

/* 行内操作列：链接之间加竖线分隔 */
.ops {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: center;
  font-size: var(--fs-sm);
  font-weight: 700;
}
.ops a { color: var(--brand); }
.ops a:hover { text-decoration: underline; }
.ops .danger,
.ops a.danger { color: var(--danger-ink); }

/* 窄屏：表格转卡片（配合 _layout.php 的 data-label 注入） */
@media (max-width: 720px) {
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl thead { display: none; }
  .tbl tr {
    background: var(--surface) !important;
    border: 1px solid var(--border-2);
    border-radius: var(--r-md);
    margin-bottom: var(--s-3);
    padding: var(--s-2) 0;
    box-shadow: var(--sh-1);
  }
  .tbl td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--s-4);
    border: 0;
    padding: 9px var(--s-4);
    text-align: right;
  }
  .tbl td::before {
    content: attr(data-label);
    font-size: var(--fs-xs);
    font-weight: 800;
    color: var(--text-3);
    text-align: left;
    flex: none;
  }
  .tbl td:empty { display: none; }
}

/* ============================================================
   10 · Status —— 徽章 / 药丸 / 状态标签
   ============================================================ */
.badge,
.pill,
.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  font-weight: 800;
  line-height: 1;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  white-space: nowrap;
  letter-spacing: .2px;
}

/* 默认态 */
.badge { background: var(--brand-l); color: var(--brand); }
.pill  { background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border-2); }
.status-tag { background: var(--brand-l); color: var(--brand); }

/* 语义修饰：三端共用同一套色值 */
.ok      { background: var(--success-l); color: var(--success-ink); }
.used,
.gray    { background: #eceff3; color: var(--text-4); }
.warn    { background: var(--warn-l);    color: var(--warn-ink); }
.danger,
.err     { background: var(--danger-l);  color: var(--danger-ink); }
.on,
.active  { background: var(--brand-l);   color: var(--brand); }

/* ============================================================
   11 · Flash
   ============================================================ */
.flash {
  margin: var(--s-3) var(--s-4) 0;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.6;
  border: 1px solid transparent;
}
.flash.ok  { background: var(--success-l); color: var(--success-ink); border-color: var(--success-bd); }
.flash.err { background: var(--danger-l);  color: var(--danger-ink);  border-color: var(--danger-bd); }

/* ============================================================
   12 · Empty —— 空状态
   ============================================================ */
.empty {
  text-align: center;
  color: var(--text-4);
  padding: var(--s-7) var(--s-4);
  font-size: var(--fs-sm);
  line-height: 1.8;
}
.empty::before {
  content: "";
  display: block;
  width: 52px;
  height: 52px;
  margin: 0 auto var(--s-3);
  border-radius: 50%;
  /* 虚线圆 + 居中横线：比纯空圆圈更有「这里是空列表」的语义 */
  background:
    linear-gradient(var(--border-3), var(--border-3)) center / 20px 2px no-repeat,
    var(--surface-3);
  border: 2px dashed var(--border-3);
}

/* 带图标的空状态（在 HTML 里直接放图标时用） */
.empty-ico {
  width: 52px;
  height: 52px;
  margin: 0 auto var(--s-3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-l);
  color: var(--brand-3);
}
.empty-ico svg { width: 26px; height: 26px; }

/* ============================================================
   13 · Utilities
   ============================================================ */

/* 统计块 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--s-3);
  margin: var(--s-4) 0;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  box-shadow: var(--sh-1);
}
.sr-k {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: .3px;
  margin-bottom: 4px;
}
.sr-v {
  display: block;
  font-size: var(--fs-xl);
  font-weight: 900;
  color: var(--text);
  letter-spacing: -.5px;
}

/* 键值列表 */
.kv-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s-3) var(--s-4);
  font-size: var(--fs-base);
}
.kv-list dt, .kv-list .k {
  color: var(--text-3);
  font-size: var(--fs-sm);
  font-weight: 700;
}
.kv-list dd, .kv-list .v {
  margin: 0;
  color: var(--text);
  font-weight: 700;
}

/* 金额 */
.amount {
  font-size: var(--fs-2xl);
  font-weight: 900;
  letter-spacing: -.6px;
  color: var(--text);
}

/* 横向滚动容器（宽表格在移动端不撑破布局） */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.scroll-x::-webkit-scrollbar { height: 5px; }
.scroll-x::-webkit-scrollbar-thumb {
  background: var(--border-3);
  border-radius: var(--r-pill);
}

/* 分隔线 */
.divider { height: 1px; background: var(--border); margin: var(--s-3) 0; }

/* 筛选栏 */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  align-items: center;
  margin-bottom: var(--s-4);
}
.filter-bar input,
.filter-bar select {
  padding: 8px 12px;
  border: 1px solid var(--border-3);
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  background: var(--surface);
  outline: none;
}
.filter-bar input:focus,
.filter-bar select:focus {
  border-color: var(--brand-3);
  box-shadow: 0 0 0 3px var(--brand-l);
}

/* 分页 */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: var(--s-4);
  font-size: var(--fs-sm);
  flex-wrap: wrap;
}

/* ---------- 尊重系统的减少动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- 窄屏微调 ---------- */
@media (max-width: 360px) {
  .btn-primary { font-size: var(--fs-base); padding: 12px var(--s-4); }
  .panel { margin-left: var(--s-3); margin-right: var(--s-3); }
}
