/* ========== Design Tokens ========== */
:root {
  --c-primary: #D90000;
  --c-secondary: #0055AA;
  --c-bg: #F5F7FA;
  --c-card: #FFFFFF;
  --c-success: #00AA55;
  --c-warning: #FF8800;
  --c-text-1: #333333;
  --c-text-2: #666666;
  --c-text-3: #999999;
  --c-border: #EAEEF3;
  --r-card: 12px;
  --r-btn: 20px;
  --r-input: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  color: var(--c-text-1);
  background: var(--c-bg);
  font-size: 14px;
  line-height: 1.5;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: 0; outline: 0; }
input, select, textarea { font-family: inherit; outline: 0; }
ul { list-style: none; }
img { display: block; max-width: 100%; }

/* ========== Layout ========== */
.app-header {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header .logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 15px; color: var(--c-text-1);
}
.app-header .logo-mark {
  width: 32px; height: 32px;
  background: var(--c-primary); color: #fff;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.app-header .nav-actions { display: flex; gap: 16px; align-items: center; }
.role-pill {
  padding: 5px 12px; background: var(--c-bg); border-radius: 12px;
  font-size: 12px; color: var(--c-text-2); cursor: pointer;
}
.role-pill.active { color: var(--c-primary); background: rgba(217,0,0,0.1); }
.icon-btn {
  background: transparent; padding: 6px 8px; border-radius: 8px;
  position: relative; font-size: 16px;
}
.icon-btn:hover { background: var(--c-bg); }
.dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; background: var(--c-primary); border-radius: 50%; }

/* ========== PC 顶部主导航（竞培训系统） ========== */
.top-nav {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.tn-logo {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; flex-shrink: 0;
}
.tn-logo-mark {
  width: 32px; height: 32px;
  background: linear-gradient(135deg,#D90000,#FF4444);
  color: #fff; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
}
.tn-logo-text {
  font-weight: 600; font-size: 15px; color: var(--c-text-1);
  white-space: nowrap;
}
.tn-menu {
  display: flex; gap: 4px; align-items: center;
  width: 1200px;
  margin: 0 auto;
  justify-content: space-evenly;
}
.tn-item {
  padding: 8px 16px; border-radius: 8px;
  font-size: 13px; color: var(--c-text-2);
  cursor: pointer; transition: all .15s;
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.tn-item:hover {
  background: var(--c-bg); color: var(--c-text-1);
}
.tn-item.active {
  color: var(--c-primary);
  background: rgba(217,0,0,0.06);
  font-weight: 600;
}
.tn-icon { font-size: 15px; }
.tn-user { flex-shrink: 0; }
.tn-user-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 20px;
  cursor: pointer; transition: background .15s;
}
.tn-user-btn:hover { background: var(--c-bg); }
.tn-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg,#0055AA,#4A90D9);
  color: #fff; display: flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 600;
}
.tn-name { font-size: 13px; color: var(--c-text-1); }
.tn-drop {
  position: absolute; top: 42px; right: 0;
  background: #fff; box-shadow: var(--shadow-lg);
  border-radius: 10px; min-width: 180px;
  padding: 4px 0; z-index: 200;
}
.tn-drop-item {
  padding: 10px 16px; font-size: 13px; color: #333;
  cursor: pointer; transition: background .1s;
}
.tn-drop-item:hover { background: var(--c-bg); }

.layout {
  display: flex;
  min-height: calc(100vh - 56px);
}
.sidebar {
  width: 220px;
  background: #fff;
  border-right: 1px solid var(--c-border);
  padding: 16px 0;
  flex-shrink: 0;
}
.sidebar .menu-item {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--c-text-2);
  font-size: 14px;
  border-right: 3px solid transparent;
  transition: background .2s;
}
.sidebar .menu-item:hover { background: var(--c-bg); color: var(--c-text-1); }
.sidebar .menu-item.active {
  background: rgba(217,0,0,0.06);
  color: var(--c-primary);
  border-right-color: var(--c-primary);
  font-weight: 600;
}
.sidebar-title {
  padding: 8px 20px;
  font-size: 11px;
  color: var(--c-text-3);
  letter-spacing: 1px;
}
.main {
  flex: 1;
  padding: 20px 24px;
  overflow-x: hidden;
  min-width: 0;
}
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* ========== Cards ========== */
.card {
  background: #fff;
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-sub { color: var(--c-text-3); font-size: 12px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.metric-card {
  background: #fff;
  border-radius: var(--r-card);
  padding: 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.metric-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  background: linear-gradient(135deg, transparent, rgba(217,0,0,0.08));
  border-radius: 0 var(--r-card) 0 80px;
}
.metric-label { color: var(--c-text-3); font-size: 13px; }
.metric-value {
  font-size: 28px; font-weight: 700;
  margin: 8px 0 4px;
  background: linear-gradient(90deg, var(--c-primary), var(--c-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.metric-trend { font-size: 12px; color: var(--c-success); }
.metric-trend.down { color: var(--c-primary); }

/* ========== Buttons ========== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: var(--r-btn);
  font-size: 14px; transition: all .2s;
  background: #fff; border: 1px solid var(--c-border); color: var(--c-text-1);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.btn-primary:hover { background: #B00000; }
.btn-secondary { background: var(--c-secondary); color: #fff; border-color: var(--c-secondary); }
.btn-secondary:hover { background: #003F80; }
.btn-success { background: var(--c-success); color: #fff; border-color: var(--c-success); }
.btn-ghost { background: transparent; color: var(--c-text-1); }
.btn-text { background: transparent; color: var(--c-secondary); padding: 4px 8px; border: 0; }
.btn-text:hover { box-shadow: none; }
.btn-danger { background: transparent; color: var(--c-primary); border-color: var(--c-primary); }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }
.btn-disabled, .btn:disabled {
  background: #ddd; color: #999; cursor: not-allowed; border-color: #ddd;
}
.btn-disabled:hover, .btn:disabled:hover { transform: none; box-shadow: none; }

/* ========== Form ========== */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; color: var(--c-text-2); margin-bottom: 6px; }
.form-row .input,
.form-row input,
.form-row select,
.form-row textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-input);
  font-size: 14px;
  background: #fff;
  transition: border-color .2s;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus { border-color: var(--c-secondary); }
.form-row textarea { min-height: 80px; resize: vertical; }
.form-row.inline { display: flex; align-items: center; gap: 12px; }
.form-row.inline label { width: 100px; margin-bottom: 0; flex-shrink: 0; }

/* ========== Table ========== */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--c-border);
  font-size: 13px;
}
.tbl th {
  color: var(--c-text-3);
  font-weight: 500;
  background: var(--c-bg);
}
.tbl tbody tr:hover { background: rgba(0,85,170,0.02); }
.tbl .actions { display: flex; gap: 8px; }

/* ========== Badge / Tag ========== */
.tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 4px;
  background: var(--c-bg);
  color: var(--c-text-2);
  line-height: 1.6;
}
.tag.success { background: rgba(0,170,85,0.12); color: var(--c-success); }
.tag.warning { background: rgba(255,136,0,0.12); color: #FF8800; }
.tag.danger { background: rgba(217,0,0,0.12); color: var(--c-primary); }
.tag.info { background: rgba(0,85,170,0.12); color: var(--c-secondary); }

/* ========== Toast ========== */
.toast-wrap {
  position: fixed; top: 24px; left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 10px 18px;
  border-radius: 8px;
  background: rgba(0,0,0,0.8);
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .3s ease;
  white-space: nowrap;
}
.toast.success { background: var(--c-success); }
.toast.error { background: var(--c-primary); }
.toast.warning { background: #FF8800; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* ========== Modal ========== */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; animation: fadeIn .2s ease;
}
.modal {
  background: #fff;
  border-radius: var(--r-card);
  padding: 24px;
  min-width: 380px;
  max-width: 90vw;
  max-height: 80vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn .25s ease;
}
.modal-title {
  font-size: 16px; font-weight: 600; margin-bottom: 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-close { cursor: pointer; color: var(--c-text-3); font-size: 18px; }
.modal-actions { margin-top: 18px; display: flex; gap: 10px; justify-content: flex-end; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }

/* ========== Token tag ========== */
.token-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  background: linear-gradient(90deg, #FFE5E5, #E5EFFF);
  color: var(--c-secondary);
  font-size: 12px;
  font-weight: 500;
}
.token-tag::before { content: "🤖"; }
.token-result {
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--c-bg);
  border-radius: 8px;
  font-size: 12px;
  color: var(--c-text-2);
  display: flex;
  justify-content: space-between;
}

/* ========== Demo guide FAB ========== */
.demo-fab {
  position: fixed; right: 24px; top: 80px;
  background: var(--c-primary); color: #fff;
  padding: 10px 16px;
  border-radius: 24px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(217,0,0,0.4);
  z-index: 999;
  font-size: 13px;
  font-weight: 500;
  user-select: none;
}
.demo-fab:hover { transform: translateY(-2px); }
.demo-tip {
  position: fixed; background: #fff;
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  max-width: 300px;
  border-left: 4px solid var(--c-primary);
}
.demo-tip-step { font-size: 12px; color: var(--c-primary); margin-bottom: 6px; font-weight: 600; }
.demo-tip-content { font-size: 13px; color: var(--c-text-2); margin-bottom: 12px; }
.demo-tip-actions { display: flex; gap: 8px; justify-content: flex-end; }
.demo-highlight {
  outline: 3px solid var(--c-primary) !important;
  outline-offset: 4px;
  border-radius: 8px;
  animation: pulse 1.4s infinite;
  position: relative;
  z-index: 9998;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217,0,0,0.4); }
  50% { box-shadow: 0 0 0 12px rgba(217,0,0,0); }
}

/* ========== Section / Page ========== */
.page-title {
  font-size: 22px; font-weight: 600; margin-bottom: 6px;
}
.page-sub { color: var(--c-text-3); margin-bottom: 20px; font-size: 13px; }
.section { margin-bottom: 24px; }

/* ========== Util ========== */
.flex { display: flex; }
.flex-1 { flex: 1; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.flex-gap { display: flex; gap: 12px; }
.flex-col { display: flex; flex-direction: column; }
.grid { display: grid; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.text-c { text-align: center; }
.text-r { text-align: right; }
.text-1 { color: var(--c-text-1); }
.text-2 { color: var(--c-text-2); }
.text-3 { color: var(--c-text-3); }
.text-primary { color: var(--c-primary); }
.text-secondary { color: var(--c-secondary); }
.text-success { color: var(--c-success); }
.text-bold { font-weight: 600; }
.text-sm { font-size: 12px; }
.text-lg { font-size: 16px; }
.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; } .mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.w-full { width: 100%; }

/* ========== Loading ========== */
.loading-mask {
  position: fixed; inset: 0;
  background: rgba(255,255,255,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 999; flex-direction: column; gap: 12px;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid #eee;
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Progress ========== */
.progress {
  width: 100%; height: 8px;
  background: #eee; border-radius: 4px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--c-secondary), var(--c-primary));
  transition: width .3s;
  border-radius: 4px;
}

/* ========== Avatar ========== */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c-primary), var(--c-secondary));
  color: #fff; display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 14px; font-weight: 500;
}
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.avatar.xs { width: 24px; height: 24px; font-size: 11px; }

/* ========== Empty ========== */
.empty {
  padding: 40px; text-align: center;
  color: var(--c-text-3); font-size: 13px;
}
.empty::before { content: "📭"; display: block; font-size: 40px; margin-bottom: 8px; }
