/* =====================================================================
 * 厦门大学体育教学部研究生奖学金综合测评自评工具 —— 样式表
 * ===================================================================== */

:root {
  --xmu-blue: #0b3d91;          /* 厦大深蓝 */
  --xmu-blue-light: #1a5fb4;
  --xmu-red: #c8102e;           /* 校徽红 */
  --xmu-gold: #b8860b;
  --bg: #f4f6fa;
  --card-bg: #ffffff;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: #e2e8f0;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
  --footer-h: 64px;
  --app-height: 100vh;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  overscroll-behavior-y: none;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  touch-action: manipulation;
}

body {
  height: var(--app-height, 100vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- 顶部标题栏 ---------- */
.app-header {
  background: linear-gradient(135deg, var(--xmu-blue) 0%, var(--xmu-blue-light) 100%);
  color: #fff;
  padding: 14px 16px 12px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(11, 61, 145, 0.25);
}
.app-header .header-row {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 960px;
  margin: 0 auto;
}
.app-header .badge {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: #fff;
  padding: 3px;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.app-header .badge img { width: 100%; height: 100%; object-fit: contain; display: block; }
.app-header h1 { font-size: 17px; font-weight: 600; line-height: 1.3; }
.app-header .subtitle { font-size: 12px; opacity: 0.85; margin-top: 2px; }

/* ---------- 步骤条 ---------- */
.steps {
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  overflow-x: auto;
  flex-shrink: 0;
}
.step {
  flex: 1;
  min-width: 90px;
  text-align: center;
  font-size: 11px;
  color: var(--text-light);
  position: relative;
  padding: 4px 2px;
}
.step .num {
  display: inline-block;
  width: 20px; height: 20px;
  line-height: 20px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #6b7280;
  font-weight: 600;
  margin-right: 4px;
  font-size: 11px;
}
.step.active { color: var(--xmu-blue); font-weight: 600; }
.step.active .num { background: var(--xmu-blue); color: #fff; }

/* ---------- Tab 栏 ---------- */
.tab-bar {
  display: flex;
  background: #fff;
  border-bottom: 2px solid var(--xmu-blue);
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}
.tab-btn {
  flex: 1;
  min-width: 88px;
  padding: 12px 8px;
  background: none;
  border: none;
  font-size: 14px;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all .15s;
  white-space: nowrap;
}
.tab-btn.active {
  color: var(--xmu-blue);
  font-weight: 600;
  border-bottom-color: var(--xmu-red);
}
.tab-btn .tab-badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  height: 18px;
  line-height: 18px;
  border-radius: 9px;
  background: var(--xmu-red);
  color: #fff;
  font-size: 10px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ---------- 内容区 ---------- */
.main-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px 12px 140px; /* 底部留出操作栏高度 */
}
.tab-panel { display: none; max-width: 960px; margin: 0 auto; }
.tab-panel.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border: 1px solid var(--border);
}
.card h2 {
  font-size: 15px;
  color: var(--xmu-blue);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--xmu-blue);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h2 .mod-tag {
  background: var(--xmu-blue);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: normal;
}
.card h3 {
  font-size: 14px;
  margin: 14px 0 8px;
  color: var(--text);
  font-weight: 600;
}
.card .note {
  font-size: 12px;
  color: var(--text-light);
  background: #f8fafc;
  border-left: 3px solid var(--xmu-blue-light);
  padding: 6px 10px;
  margin: 8px 0;
  border-radius: 0 4px 4px 0;
}

/* ---------- 表单 ---------- */
.form-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
}
.form-row label {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 4px;
  font-weight: 500;
}
.form-row label .req { color: var(--danger); margin-left: 2px; }
.form-row .hint { font-size: 11px; color: var(--text-light); margin-top: 3px; }
input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 16px;   /* 防止 iOS 自动缩放 */
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
  -webkit-appearance: none;
  appearance: none;
}
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
input:focus, select:focus, textarea:focus { border-color: var(--xmu-blue); box-shadow: 0 0 0 2px rgba(11,61,145,0.12); }
input.invalid { border-color: var(--danger); background: #fef2f2; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* 复选框/单选 */
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-size: 14px;
}
.check-row input[type="checkbox"], .check-row input[type="radio"] {
  width: 18px; height: 18px;
  accent-color: var(--xmu-blue);
}

/* ---------- 多条录入 ---------- */
.record-list { display: flex; flex-direction: column; gap: 10px; }
.record-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #fafbfd;
  position: relative;
}
.record-item .item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.record-item .item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--xmu-blue);
}
.record-item .item-score {
  font-size: 14px;
  font-weight: 700;
  color: var(--xmu-red);
}
.record-item .grid-2, .record-item .grid-3 { margin-bottom: 6px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  min-height: 44px;
  transition: all .15s;
}
.btn-primary { background: var(--xmu-blue); color: #fff; }
.btn-primary:hover { background: #0a357e; }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-outline { background: #fff; color: var(--xmu-blue); border: 1px solid var(--xmu-blue); }
.btn-outline:hover { background: #eff6ff; }
.btn-sm { padding: 6px 12px; min-height: 32px; font-size: 12px; }
.btn-add {
  background: #eff6ff;
  color: var(--xmu-blue);
  border: 1px dashed var(--xmu-blue-light);
  width: 100%;
  margin-top: 8px;
}
.btn-add:hover { background: #dbeafe; }

/* ---------- 底部固定操作栏 ---------- */
.bottom-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 10px 12px calc(env(safe-area-inset-bottom, 0px) + 10px);
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
}
.bottom-bar .bar-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
}
.bottom-bar .btn { flex: 1; }

/* ---------- 结果区 ---------- */
.result-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 12px 0;
}
.result-card {
  background: linear-gradient(135deg, #f8fafc, #eff6ff);
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}
.result-card .label { font-size: 12px; color: var(--text-light); }
.result-card .value { font-size: 22px; font-weight: 700; color: var(--xmu-blue); margin-top: 4px; }
.result-card.weighted .value { color: var(--xmu-red); }
.result-card.total {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--xmu-blue), var(--xmu-blue-light));
  border: none;
  color: #fff;
  padding: 18px;
}
.result-card.total .label { color: rgba(255,255,255,0.85); }
.result-card.total .value { color: #fff; font-size: 32px; }

.alert {
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin: 8px 0;
}
.alert-info { background: #eff6ff; color: #1e40af; border-left: 4px solid var(--xmu-blue); }
.alert-warn { background: #fffbeb; color: #92400e; border-left: 4px solid var(--warn); }
.alert-danger { background: #fef2f2; color: #991b1b; border-left: 4px solid var(--danger); }
.alert-success { background: #f0fdf4; color: #166534; border-left: 4px solid var(--success); }

.detail-list { font-size: 13px; margin-top: 8px; }
.detail-list .row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}
.detail-list .row:last-child { border-bottom: none; }
.detail-list .row .name { flex: 1; padding-right: 10px; }
.detail-list .row .score { font-weight: 600; color: var(--xmu-blue); white-space: nowrap; }
.detail-list .row.capped .score { color: var(--warn); }
.detail-list .row.trimmed .score { color: var(--danger); text-decoration: line-through; }

/* ---------- 细则折叠 ---------- */
details.rule-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fff;
  overflow: hidden;
}
details.rule-block summary {
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 600;
  color: var(--xmu-blue);
  background: #f8fafc;
  list-style: none;
  position: relative;
  padding-right: 36px;
}
details.rule-block summary::-webkit-details-marker { display: none; }
details.rule-block summary::after {
  content: '+';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--xmu-blue);
  font-weight: 400;
}
details.rule-block[open] summary::after { content: '−'; }
details.rule-block .rule-body {
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.8;
}
details.rule-block .rule-body p { margin-bottom: 6px; }

.search-box {
  margin-bottom: 12px;
}

/* ---------- 资格自查 ---------- */
.qual-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border-radius: 6px;
  margin-bottom: 6px;
  background: #f8fafc;
}
.qual-item input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--xmu-blue); }
.qual-item.veto { background: #fef2f2; }
.qual-item.veto input { accent-color: var(--danger); }
.qual-item .q-label { font-size: 13px; flex: 1; }

/* ---------- 导出预览/弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-mask.show { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 600px;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-light);
  padding: 4px 8px;
  min-width: 44px;
}
.modal-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 300;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
  max-width: 80%;
  text-align: center;
}
.toast.show { opacity: 1; }

/* ---------- 页脚 ---------- */
.app-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-light);
  padding: 16px;
  line-height: 1.6;
}

/* =====================================================================
 * 打印样式 —— A4 纵向规范申报表
 * ===================================================================== */
@media print {
  @page { size: A4 portrait; margin: 14mm 12mm; }

  html, body {
    height: auto !important;
    overflow: visible !important;
    background: #fff !important;
  }
  body { display: block; }

  /* 隐藏所有非打印元素 */
  .app-header, .steps, .tab-bar, .bottom-bar, .no-print, .app-footer, .toast, .modal-mask {
    display: none !important;
  }

  .main-content {
    padding: 0 !important;
    overflow: visible !important;
    height: auto !important;
  }
  .tab-panel { display: none !important; }
  .tab-panel.print-only { display: block !important; max-width: none !important; }

  #print-area {
    display: block !important;
    color: #000;
    font-size: 12pt;
    line-height: 1.5;
  }
  #print-area .print-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 10px;
  }
  #print-area .print-header img {
    width: 60px; height: 60px;
  }
  #print-area .print-title {
    font-size: 18pt;
    font-weight: bold;
    text-align: center;
    letter-spacing: 2px;
  }
  #print-area .print-subtitle {
    text-align: center;
    font-size: 11pt;
    margin-bottom: 12px;
    color: #333;
  }
  #print-area table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 8px;
    font-size: 10.5pt;
  }
  #print-area th, #print-area td {
    border: 1px solid #000;
    padding: 5px 7px;
    vertical-align: middle;
  }
  #print-area th {
    background: #e8eef7 !important;
    font-weight: bold;
    text-align: center;
  }
  #print-area .info-row td { padding: 6px 8px; }
  #print-area .section-title {
    background: #d6e0f0 !important;
    font-weight: bold;
    padding: 6px 8px;
    border: 1px solid #000;
    margin-top: 8px;
  }
  #print-area .total-row td {
    font-weight: bold;
    background: #fff7e0 !important;
  }
  #print-area .sign-area {
    margin-top: 24px;
    display: flex;
    justify-content: space-between;
    font-size: 11pt;
  }
  #print-area .sign-block { width: 48%; }
  #print-area .sign-line {
    border-bottom: 1px solid #000;
    height: 28px;
    margin-top: 4px;
  }
  #print-area .promise {
    margin-top: 16px;
    font-size: 11pt;
  }
  #print-area tr { page-break-inside: avoid; }
}

/* =====================================================================
 * 响应式
 * ===================================================================== */
@media (max-width: 480px) {
  .app-header h1 { font-size: 15px; }
  .app-header .badge { width: 40px; height: 40px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .result-summary { grid-template-columns: 1fr 1fr; }
  .result-card.total .value { font-size: 26px; }
  .bottom-bar .bar-inner { flex-direction: row; }
}
@media (min-width: 481px) and (max-width: 768px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 769px) {
  .main-content { padding: 20px 24px 140px; }
  .card { padding: 20px; }
}
