/* ==========================================================================
   天府十小 · 智慧体育平台 / 基础设计系统
   零依赖、无 CDN，全部样式本地化，可直接 file:// 打开
   ========================================================================== */
:root {
  --bg: #f3f6fa;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --border: #e4eaf1;
  --border-strong: #d3dce7;
  --text: #17263c;
  --text-2: #465870;
  --muted: #8494a9;
  --primary: #0e9f8e;
  --primary-dark: #0a8577;
  --primary-soft: #e4f6f2;
  --blue: #2f6bff;
  --blue-soft: #eaf0ff;
  --orange: #ff8a3d;
  --orange-soft: #fff1e6;
  --red: #e94b57;
  --red-soft: #fdecee;
  --green: #16a46a;
  --green-soft: #e6f6ee;
  --purple: #7a63e8;
  --purple-soft: #f0ecff;
  --sidebar: #10243a;
  --sidebar-2: #17304a;
  --shadow: 0 2px 10px rgba(20, 42, 70, .05);
  --shadow-lg: 0 12px 40px rgba(20, 42, 70, .14);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
a { color: var(--blue); text-decoration: none; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cdd7e3; border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #aebdcf; background-clip: padding-box; }

/* ---------- 通用工具 ---------- */
.hidden { display: none !important; }
.row { display: flex; align-items: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.right { text-align: right; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 18px 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 650; letter-spacing: .2px; margin: 0; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 18px 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--panel-2); border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: #fff; color: var(--text-2);
  font-weight: 550; white-space: nowrap; transition: .16s ease;
}
.btn:hover { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-blue:hover { background: #1d55e0; border-color: #1d55e0; color: #fff; }
.btn-danger { color: var(--red); border-color: #f2c9cd; background: #fff; }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 42px; padding: 0 22px; font-size: 15px; }
.btn-icon { width: 34px; padding: 0; font-size: 16px; }
.btn svg { width: 15px; height: 15px; }

/* ---------- 标签 / 状态 ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600;
  background: var(--panel-2); color: var(--text-2); border: 1px solid var(--border);
  white-space: nowrap;
}
.tag-green { background: var(--green-soft); color: var(--green); border-color: #c8ead9; }
.tag-blue { background: var(--blue-soft); color: var(--blue); border-color: #d1ddff; }
.tag-orange { background: var(--orange-soft); color: #d9681d; border-color: #ffdcc2; }
.tag-red { background: var(--red-soft); color: var(--red); border-color: #f7ced2; }
.tag-purple { background: var(--purple-soft); color: var(--purple); border-color: #ddd5ff; }
.tag-gray { background: #f0f3f7; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
.dot-green { background: var(--green); box-shadow: 0 0 0 3px rgba(22,164,106,.14); }
.dot-red { background: var(--red); box-shadow: 0 0 0 3px rgba(233,75,87,.14); }
.dot-orange { background: var(--orange); box-shadow: 0 0 0 3px rgba(255,138,61,.15); }
.dot-gray { background: #b6c2d1; }

/* ---------- 表格 ---------- */
.table-wrap { overflow: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 12px;
  padding: 10px 14px; background: var(--panel-2); border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
.table td { padding: 11px 14px; border-bottom: 1px solid #eef2f6; color: var(--text-2); vertical-align: middle; }
.table tbody tr:hover td { background: #f7fbfc; }
.table tbody tr:last-child td { border-bottom: none; }
.table .strong { color: var(--text); font-weight: 600; }
.table-compact td { padding: 8px 12px; }
.table-scroll { max-height: 340px; overflow: auto; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: #fff; color: var(--text); outline: none;
  transition: .15s;
}
.textarea { height: auto; min-height: 70px; padding: 8px 10px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14,159,142,.12); }
.input::placeholder { color: #adb9c8; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #8494a9 50%), linear-gradient(135deg, #8494a9 50%, transparent 50%); background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.check input { accent-color: var(--primary); width: 15px; height: 15px; }

/* ---------- 指标卡 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::after { content: ''; position: absolute; right: -18px; top: -18px; width: 74px; height: 74px; border-radius: 50%; background: var(--primary-soft); opacity: .6; }
.stat-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 27px; font-weight: 700; line-height: 1.25; margin-top: 6px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.stat-foot { font-size: 12px; color: var(--muted); margin-top: 6px; }
.stat-foot .up { color: var(--green); font-weight: 600; }
.stat-foot .down { color: var(--red); font-weight: 600; }
.stat.tint-blue::after { background: var(--blue-soft); }
.stat.tint-orange::after { background: var(--orange-soft); }
.stat.tint-purple::after { background: var(--purple-soft); }
.stat.tint-red::after { background: var(--red-soft); }

/* ---------- 进度条 ---------- */
.progress { height: 7px; border-radius: 6px; background: #edf1f6; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 6px; background: var(--primary); transition: width .4s ease; }
.progress.thin { height: 5px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  padding: 9px 16px 11px; border: none; background: transparent; color: var(--muted);
  font-weight: 600; white-space: nowrap; border-bottom: 2px solid transparent; transition: .15s;
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--primary-dark); border-bottom-color: var(--primary); }

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(12, 28, 46, .48); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  backdrop-filter: blur(2px); animation: fadeIn .16s ease;
}
.modal {
  width: min(560px, 100%); max-height: 86vh; overflow: auto; background: #fff;
  border-radius: 14px; box-shadow: var(--shadow-lg); animation: popIn .18s ease;
}
.modal.wide { width: min(820px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--panel-2); }
.modal-close { border: none; background: transparent; font-size: 22px; line-height: 1; color: var(--muted); padding: 0 4px; }
.modal-close:hover { color: var(--text); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Toast ---------- */
#toastHost { position: fixed; right: 22px; top: 22px; z-index: 300; display: flex; flex-direction: column; gap: 9px; pointer-events: none; }
.toast {
  min-width: 220px; max-width: 360px; padding: 11px 15px; border-radius: 10px;
  background: #162a41; color: #fff; box-shadow: var(--shadow-lg); font-size: 13px;
  display: flex; align-items: center; gap: 9px; animation: slideIn .2s ease;
}
.toast.ok { background: #0d8a6a; }
.toast.warn { background: #c96a24; }
.toast.err { background: #cf3d49; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---------- 空态 / 加载 ---------- */
.empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.empty .empty-icon { font-size: 30px; display: block; margin-bottom: 8px; opacity: .55; }

/* ---------- 图表容器 ---------- */
.chart { width: 100%; overflow: visible; }
.chart text { font-family: var(--font); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }
