[hidden] { display: none !important; }

/* ===== JSTest 竞赛系统 - 主题与响应式 ===== */
:root, [data-theme="classic"] {
  --bg-primary: #f7f4f0; --bg-card: #ffffff; --bg-sidebar: #8c1f28;
  --text-primary: #2b2b2b; --text-muted: #8a8a94; --text-on-sidebar: #ffe9c9;
  --accent: #c8102e; --accent-soft: #fde8eb; --gold: #d4a017;
  --border: #e8e2da; --danger: #d9534f; --success: #2e9e5b; --warn: #e6a23c;
}
[data-theme="redgold"] {
  --bg-primary: #7a1620; --bg-card: #93222d; --bg-sidebar: #5e0f17;
  --text-primary: #fff3e0; --text-muted: #e8b9a0; --text-on-sidebar: #ffd970;
  --accent: #ffd970; --accent-soft: #b3404a; --gold: #ffd970;
  --border: #b3404a; --danger: #ff8a80; --success: #81c784; --warn: #ffd970;
}
[data-theme="blue"] {
  --bg-primary: #f0f4f9; --bg-card: #ffffff; --bg-sidebar: #12294d;
  --text-primary: #1c2b40; --text-muted: #7c8ba1; --text-on-sidebar: #cfe3ff;
  --accent: #2469d4; --accent-soft: #e3edfc; --gold: #f2a93b;
  --border: #d8e2ef; --danger: #d9534f; --success: #2e9e5b; --warn: #e6a23c;
}
[data-theme="dark"] {
  --bg-primary: #10141f; --bg-card: #1a2130; --bg-sidebar: #0a0d15;
  --text-primary: #e8ecf4; --text-muted: #8b95a8; --text-on-sidebar: #9db8ff;
  --accent: #4d7cff; --accent-soft: #232e45; --gold: #f2c94c;
  --border: #2a3446; --danger: #ef6b6b; --success: #4fc98a; --warn: #f2c94c;
}
[data-theme="light"] {
  --bg-primary: #ffffff; --bg-card: #fafafa; --bg-sidebar: #33383f;
  --text-primary: #22262b; --text-muted: #9aa1a9; --text-on-sidebar: #ffffff;
  --accent: #22262b; --accent-soft: #eef0f2; --gold: #c9a227;
  --border: #e6e8ea; --danger: #d9534f; --success: #2e9e5b; --warn: #e6a23c;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg-primary); color: var(--text-primary);
  min-height: 100vh; -webkit-font-smoothing: antialiased;
}

/* ===== 布局：侧栏 + 主区 ===== */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 216px; background: var(--bg-sidebar); color: var(--text-on-sidebar);
  padding: 20px 0; flex-shrink: 0; display: flex; flex-direction: column;
}
.sidebar .logo { padding: 0 20px 18px; font-size: 17px; font-weight: 700; letter-spacing: 1px; }
.sidebar .logo small { display: block; font-size: 11px; opacity: .7; font-weight: 400; margin-top: 4px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 12px 20px;
  color: var(--text-on-sidebar); text-decoration: none; font-size: 14px;
  opacity: .78; border-left: 3px solid transparent; transition: all .15s;
}
.sidebar nav a:hover { opacity: 1; background: rgba(255,255,255,.08); }
.sidebar nav a.active { opacity: 1; border-left-color: var(--accent); background: rgba(255,255,255,.12); font-weight: 600; }
.sidebar .role-badge { margin: auto 16px 0; padding: 10px 12px; background: rgba(255,255,255,.1); border-radius: 10px; font-size: 12px; }
.sidebar .role-badge b { display: block; font-size: 13px; margin-bottom: 2px; }
.sidebar .role-badge a { color: var(--text-on-sidebar); opacity: .7; font-size: 12px; text-decoration: underline; }

.main { flex: 1; padding: 24px 28px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 10px; }
.topbar h1 { font-size: 22px; font-weight: 700; }
.topbar .sub { color: var(--text-muted); font-size: 13px; margin-top: 3px; }

/* ===== 卡片/表格/表单 ===== */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; padding: 20px; margin-bottom: 18px; }
.card h2 { font-size: 16px; margin-bottom: 14px; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stat { background: var(--accent-soft); border-radius: 12px; padding: 16px; }
.stat .num { font-size: 28px; font-weight: 800; color: var(--accent); }
.stat .lbl { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
tr:hover td { background: var(--accent-soft); }
.table-wrap { overflow-x: auto; }

/* ===== 分页器（v2.14）：此前 .pager 无任何样式，按钮按行内流随意换行，
   点页码时整块高度变化导致"画面乱弹"。改为固定高度 flex 布局，页码不再位移。 ===== */
.pager {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 0 2px; min-height: 46px; box-sizing: border-box;
}
.pg-info { font-size: 12.5px; color: var(--text-muted); }
.pg-info b { color: var(--text-primary); font-weight: 700; }
.pager label { margin: 0; font-size: 12.5px; display: inline-flex; align-items: center; gap: 5px; }
.pager select { width: auto; min-width: 64px; padding: 6px 8px; font-size: 12.5px; border-radius: 8px; }

.btn { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }
.pg-jump { width: 74px !important; padding: 6px 8px; font-size: 12.5px; text-align: center; border-radius: 8px; }
.pg-ellipsis { color: var(--text-muted); padding: 0 2px; }
.pg-gap { flex: 1 1 auto; }

input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; background: var(--bg-card); color: var(--text-primary); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
label { display: block; font-size: 12px; color: var(--text-muted); margin: 12px 0 6px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > div { flex: 1; min-width: 180px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border: none; border-radius: 10px; font-size: 14px; font-weight: 600;
  cursor: pointer; background: var(--accent); color: #fff; transition: opacity .15s;
}
.btn:hover { opacity: .88; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; background: var(--accent-soft); color: var(--accent); }
.tag.ok { background: rgba(46,158,91,.15); color: var(--success); }
.tag.off { background: rgba(217,83,79,.15); color: var(--danger); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 140px; }
.spacer { flex: 1; }

/* ===== Toast ===== */
#toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  background: var(--text-primary); color: var(--bg-card); padding: 11px 22px;
  border-radius: 999px; font-size: 14px; z-index: 999; opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
#toast.show { opacity: 1; }
#toast.error { background: var(--danger, #c62828); color: #fff; }

/* ===== 登录页 ===== */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--bg-sidebar), var(--accent)); padding: 20px;
}
.login-card {
  background: var(--bg-card); border-radius: 20px; padding: 38px 34px;
  width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-card h1 { font-size: 21px; margin-bottom: 6px; }
.login-card p { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }

/* ===== 手机适配 ===== */
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; padding: 12px 0; }
  .sidebar .logo { padding: 8px 16px 10px; }
  .sidebar nav { display: flex; overflow-x: auto; padding: 0 8px; }
  .sidebar nav a { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; padding: 10px 14px; }
  .sidebar nav a.active { border-left: none; border-bottom-color: var(--accent); }
  .sidebar .role-badge { margin: 10px 16px 0; }
  .main { padding: 16px 14px; }
  .topbar h1 { font-size: 18px; }
  table { font-size: 12px; }
  th, td { padding: 8px 8px; }
  .btn { padding: 12px 18px; }  /* 触控目标 */
  input, select { font-size: 16px; }  /* 防iOS缩放 */
}

/* ===== 大屏基础（bigscreen页另设） ===== */
@media (min-width: 1600px) {
  html { font-size: 18px; }
  .sidebar { width: 250px; }
}
