/* ==========================================================
   运筹学 · 可视化复习 — 样式表
   基于数据挖掘复习系统的视觉语言，新增公式框 / 算法演示 / 逐步表格
   ========================================================== */
:root {
  --navy: #10233B;
  --accent: #1D4ED8;
  --accent2: #0F766E;
  --exam: #B45309;
  --hot: #C2410C;
  --bg: #F4F7FA;
  --card: #FFFFFF;
  --text: #233346;
  --muted: #5B6B7F;
  --border: #D8E1EA;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); }
body { min-height: 100vh; }

/* ===== 顶栏 ===== */
.topbar {
  background: var(--navy); color: #fff; padding: 14px 20px;
  display: flex; gap: 18px; align-items: center;
  position: sticky; top: 0; z-index: 50; border-bottom: 2px solid var(--accent);
}
.logo {
  width: 44px; height: 44px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid; place-items: center; font-weight: 800; font-size: 20px; color: #fff;
}
.brand h1 { margin: 0; font-size: 20px; letter-spacing: 0.4px; }
.sub { margin: 2px 0 0; font-size: 12px; color: #B8C6D9; }
.tabs { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.tabs .tab {
  background: transparent; border: 1px solid rgba(255,255,255,.25); color: #cfd8e8;
  padding: 6px 14px; border-radius: 20px; font-size: 13px; cursor: pointer;
}
.tabs .tab.active { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.4); }
.tabs .tab:hover { border-color: rgba(255,255,255,.5); }

/* ===== 全局进度 ===== */
.global-progress {
  display: flex; gap: 12px; align-items: center; padding: 8px 20px;
  background: #fff; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--muted);
}
.gp-bar { flex: 1; height: 8px; background: #eef2f7; border-radius: 4px; overflow: hidden; }
.gp-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 4px; transition: width .4s; }
.next-btn {
  background: var(--accent2); color: #fff; border: none; padding: 6px 14px; border-radius: 20px;
  font-size: 12.5px; cursor: pointer; font-weight: 600;
}
.next-btn:hover { filter: brightness(.9); }

main { padding: 18px 20px; max-width: 1320px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

/* ===== 学习路径 ===== */
.path-hero {
  background: linear-gradient(135deg, var(--navy) 60%, #163350 100%);
  color: #fff; padding: 26px 28px; border-radius: var(--radius);
  margin-bottom: 18px; position: relative; overflow: hidden;
}
.path-hero::before {
  content:""; position:absolute; inset:-40px -40px auto auto;
  background: radial-gradient(circle at 100% 20%, rgba(29,78,216,.25), transparent 60%);
}
.path-hero h2 { margin: 0 0 8px; font-size: 22px; }
.path-hero p { margin: 0 0 14px; opacity: .92; font-size: 14px; }
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px;
  font-weight: 700; letter-spacing: .3px; vertical-align: middle;
}
.badge.hot { background: #FDCD78; color: #7a3a00; }
.badge.mid { background: #BFDBFE; color: #1E3A8A; }
.badge.norm { background: #E2E8F0; color: var(--muted); }
.hero-stats { display: flex; gap: 24px; font-size: 13px; opacity: .85; margin-top: 8px; flex-wrap: wrap; }
.path-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }

.path-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
  cursor: pointer; transition: transform .15s, box-shadow .15s;
}
.path-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(16,35,59,.10); border-color: var(--accent); }
.path-card .pc-no {
  width: 34px; height: 34px; border-radius: 50%; background: #E8F0FF; color: var(--accent);
  display: grid; place-items: center; font-weight: 800; font-size: 14px; float: left; margin-right: 10px;
}
.path-card h3 { margin: 0; font-size: 15px; color: var(--navy); }
.path-card .pc-en { font-size: 11.5px; color: var(--muted); margin: 2px 0 10px; }
.path-card .pc-meta { clear: both; font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.pc-bar { height: 6px; background: #eef2f7; border-radius: 3px; overflow: hidden; margin-top: 10px; }
.pc-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.pc-src { font-size: 11px; color: #93A3B5; margin-top: 8px; word-break: break-all; }

/* ===== 侧栏 ===== */
.chapter-list { display: flex; flex-direction: column; gap: 8px; }
.chapter-btn {
  width: 100%; text-align: left; padding: 10px 12px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-size: 14px; cursor: pointer;
}
.chapter-btn:hover { border-color: var(--accent); color: var(--accent); }
.chapter-btn.active { background: #E8F0FF; border-color: var(--accent); font-weight: 700; color: var(--navy); }
.chapter-btn .k { font-weight: 600; }
.chapter-btn .v { float: right; font-size: 12px; color: var(--muted); background: #f0f4f9; padding: 2px 8px; border-radius: 10px; }
.chapter-btn .cb-sub { display: block; font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 2px; }

#view-learn.active { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; align-items: start; }
.sidebar { height: fit-content; position: sticky; top: 96px; }
.content { min-height: 520px; min-width: 0; }
.empty-state { display: grid; place-items: center; text-align: center; padding: 60px 24px; color: var(--muted); min-height: 480px; }
.empty-icon { font-size: 40px; opacity: .4; margin-bottom: 10px; }
.empty-state h2 { margin: 0 0 6px; color: var(--text); }
.empty-state p { margin: 4px 0; font-size: 14px; }
.empty-state .tip { font-size: 12.5px; color: #93A3B5; }
.search-box { margin-bottom: 12px; }
.search-box input { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px; }

/* ===== 知识点卡片 ===== */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 14px; position: relative; overflow: hidden;
}
.card::before { content:""; position:absolute; left:0; top:0; width:4px; height:100%; background: var(--accent2); opacity: 0; transition: opacity .2s; }
.card.hot::before { background: var(--hot); opacity: 1; }
.card.hot { border-left: 4px solid var(--hot); padding-left: 14px; }
.card .card-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.card .card-title { font-weight: 700; font-size: 15.5px; color: var(--navy); }
.card .card-id { font-size: 11px; color: #A9B7C6; font-family: Consolas, monospace; }
.card .card-tag { font-size: 11px; padding: 1px 7px; border-radius: 10px; margin-left: auto; font-weight: 700; }
.card .tag-hot { background: #FDE9D4; color: var(--hot); }
.card .tag-mid { background: #DBEAFE; color: #1D4ED8; }
.card .tag-norm { background: #E2E8F0; color: var(--muted); }
.card .card-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 8px; }
.card .chip { font-size: 11px; background: #F1F5F9; color: var(--muted); padding: 1px 8px; border-radius: 10px; }
.card .card-body { font-size: 14px; line-height: 1.62; color: #374759; }
.card .card-body p { margin: 0 0 8px; }
.card .card-body ul { margin: 6px 0 8px; padding-left: 20px; }
.card .card-body li { margin-bottom: 4px; }
.card .card-body b, .card .card-body strong { color: var(--navy); }
.card .warn {
  display: block; background: #FFF7ED; border-left: 3px solid #F59E0B; color: #92400E;
  padding: 7px 10px; border-radius: 0 8px 8px 0; font-size: 13.5px; margin: 8px 0;
}

/* ===== 公式框 ===== */
.fx {
  background: #f0f4f9; border: 1px dashed var(--border); border-radius: 8px; padding: 9px 14px;
  margin: 8px 0; font-size: 13.5px; color: var(--navy);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  overflow-x: auto; white-space: pre-wrap;
}
.fx::before {
  content: "ƒ"; display: inline-block; margin-right: 8px; color: var(--accent);
  font-weight: 700; opacity: .55;
}
pre.mat, .steps pre {
  font-family: Consolas, 'Courier New', monospace; font-size: 12.8px; line-height: 1.5;
  background: #F6F8FB; border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; margin: 8px 0; overflow-x: auto; color: #10233B; white-space: pre;
}

/* ===== 例题 / 新题 ===== */
.q-wrap { background: #F8FAFC; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-top: 12px; }
.q-wrap.newq { background: #F0FDF4; border-color: #BBF7D0; }
.q-wrap .q-head {
  font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px;
  font-weight: 700; margin-bottom: 6px; display: flex; align-items: center; gap: 8px;
}
.q-wrap.newq .q-head { color: #15803D; }
.q-wrap .q-src { font-weight: 400; text-transform: none; letter-spacing: 0; color: #93A3B5; font-size: 11.5px; }
.q-wrap .q-body { font-size: 14px; line-height: 1.6; color: #374759; white-space: pre-wrap; }
.q-wrap .q-ans {
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed #C9D6E3;
  font-size: 14px; color: #374759; display: none; line-height: 1.6;
}
.q-wrap .q-ans.show { display: block; }
.q-wrap .q-ans .step {
  display: block; padding: 6px 0 6px 12px; border-left: 2px solid #CBD5E1; margin-bottom: 6px;
}
.q-wrap .q-ans .step b { color: var(--accent); }
.q-wrap .q-ans .step pre { margin: 5px 0 0; }
.q-wrap .q-ans .meta-row {
  display: block; background: #EFF6FF; border-radius: 8px; padding: 7px 10px; margin-top: 8px;
  font-size: 13px; color: #1E40AF;
}
.q-wrap .q-ans .meta-row.pit { background: #FEF2F2; color: #991B1B; }
.ans-btn {
  background: transparent; border: 1px solid var(--border); color: var(--accent);
  padding: 4px 11px; border-radius: 10px; font-size: 12px; cursor: pointer;
}
.ans-btn:hover { background: #EEF4FF; }
.q-wrap .done-tag { font-size: 11.5px; background: #D1FAE5; color: #065F46; padding: 1px 7px; border-radius: 10px; font-weight: 700; }

.card-tools { display: flex; gap: 8px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.mastery {
  background: #fff; border: 1px solid var(--border); color: var(--muted);
  padding: 5px 13px; border-radius: 18px; font-size: 12.5px; cursor: pointer;
}
.mastery:hover { border-color: var(--accent2); color: var(--accent2); }
.mastery.on { background: #D1FAE5; border-color: #10B981; color: #065F46; font-weight: 700; }

/* ===== 算法演示 ===== */
.algo-wrap .algo-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 16px;
}
.algo-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.algo-head h3 { margin: 0; font-size: 15.5px; color: var(--navy); }
.algo-head .algo-ch { font-size: 11.5px; background: #E8F0FF; color: var(--accent); padding: 2px 9px; border-radius: 10px; font-weight: 700; }
.algo-src { font-size: 12px; color: var(--muted); margin-bottom: 10px; }

.stepper { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.stepper .st-btn {
  background: var(--accent); color: #fff; border: none; padding: 6px 14px; border-radius: 8px;
  font-size: 13px; cursor: pointer; font-weight: 600;
}
.stepper .st-btn.ghost { background: #fff; color: var(--accent); border: 1px solid var(--border); }
.stepper .st-btn:disabled { opacity: .4; cursor: not-allowed; }
.stepper .st-pos { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stepper .st-dots { display: flex; gap: 5px; margin-left: 6px; }
.stepper .st-dots i {
  width: 9px; height: 9px; border-radius: 50%; background: #D8E1EA; cursor: pointer; display: block;
}
.stepper .st-dots i.on { background: var(--accent); transform: scale(1.25); }
.stepper .st-dots i.done { background: var(--accent2); }
.step-label { font-size: 13.5px; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.step-note { font-size: 13px; color: #374759; background: #FFFBEB; border-left: 3px solid #F59E0B; padding: 7px 10px; border-radius: 0 8px 8px 0; margin-top: 8px; }

/* 单纯形表 / 运输表 */
.tbl-scroll { overflow-x: auto; margin: 8px 0; }
table.simplex, table.transport {
  border-collapse: collapse; font-family: Consolas, 'Courier New', monospace;
  font-size: 13px; background: #fff;
}
table.simplex th, table.simplex td, table.transport th, table.transport td {
  border: 1px solid #C9D6E3; padding: 5px 9px; text-align: center; white-space: nowrap;
}
table.simplex th, table.transport th { background: #EAF1FB; color: var(--navy); font-weight: 700; }
table.simplex td.base, table.transport td.base { background: #F0FDF4; font-weight: 700; color: #166534; }
table.simplex td.pivot { background: #FDE68A; border: 2px solid #D97706; font-weight: 800; color: #7C2D12; }
table.simplex td.neg { color: #B91C1C; }
table.simplex tr.sep td { border-top: 2px solid #94A3B8; }
table.transport td.alloc { background: #EFF6FF; font-weight: 700; color: #1E40AF; }
table.transport td.cost { color: #93A3B5; font-size: 11.5px; }
table.transport th.corner { background: #F1F5F9; }
.transport-sum { display: flex; gap: 18px; font-size: 12.5px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }

/* 图解法 SVG */
.graph-box { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px; overflow-x: auto; }
.graph-box svg { display: block; max-width: 100%; height: auto; }
.graph-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; align-items: center; }
.graph-legend i { display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.graph-ctl { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.graph-ctl input[type=range] { flex: 1; min-width: 140px; accent-color: var(--accent); }
.graph-ctl .iso-val { font-size: 13px; color: var(--navy); font-weight: 700; min-width: 110px; }

/* ===== 考点 / 新题列表 ===== */
.list-wrap { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; align-items: start; }
.section-title { font-size: 16px; color: var(--navy); margin: 4px 0 12px; font-weight: 700; }
.section-title small { font-weight: 400; color: var(--muted); font-size: 12.5px; margin-left: 8px; }
.item-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.item-card.exam-item { border-left: 4px solid var(--hot); }
.item-card .item-q { font-size: 14px; line-height: 1.55; margin-bottom: 8px; color: #374759; white-space: pre-wrap; }
.item-card .item-meta {
  font-size: 12px; color: var(--muted); border-top: 1px solid #EEF2F7; padding-top: 7px;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.item-card .go { background: transparent; border: none; color: var(--accent); cursor: pointer; font-size: 12px; text-decoration: underline; padding: 0; }
.drill-count { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.drill-filter { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.drill-filter select, .drill-filter input {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 9px; font-size: 13px; background: #fff;
}
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

footer {
  background: #fff; border-top: 1px solid var(--border); padding: 12px 20px; font-size: 12px;
  color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
}
.link-btn { background: transparent; border: none; color: var(--accent); cursor: pointer; font-size: 12px; text-decoration: underline; }
.link-btn:hover { color: var(--accent2); }

@media (max-width: 900px) {
  #view-learn.active { grid-template-columns: 1fr; }
  .sidebar { order: 2; position: static; }
  .tabs { order: 3; width: 100%; justify-content: center; margin-top: 10px; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
}

/* ---------- 流程图 viz ---------- */
.flow-wrap { margin: 4px 0 2px; }
.flow-body { position: relative; padding-left: 4px; }
.flow-row { display: flex; gap: 12px; align-items: flex-start; opacity: .55; transition: opacity .2s; cursor: pointer; }
.flow-row.done { opacity: .85; }
.flow-row.on { opacity: 1; }
.flow-dot {
  flex: 0 0 28px; height: 28px; border-radius: 50%; background: #E8EDF5; color: #5B6B7F;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
  border: 2px solid transparent; transition: all .2s;
}
.flow-row.done .flow-dot { background: #D6EDE9; color: #0F766E; }
.flow-row.on .flow-dot { background: var(--accent); color: #fff; border-color: #BFD3FF; box-shadow: 0 0 0 4px rgba(29,78,216,.12); }
.flow-box {
  flex: 1; background: #F8FAFC; border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 13px; transition: all .2s;
}
.flow-row.on .flow-box { background: #fff; border-color: var(--accent); box-shadow: 0 2px 10px rgba(29,78,216,.10); }
.flow-title { font-weight: 700; font-size: 13.5px; color: var(--navy); margin-bottom: 2px; }
.flow-desc { font-size: 13px; color: #445266; line-height: 1.65; }
.flow-note { font-size: 12px; color: var(--muted); margin-top: 4px; }
.flow-line { width: 2px; height: 14px; background: #DCE3ED; margin-left: 13px; }
.flow-loop {
  margin-top: 10px; font-size: 12.5px; color: #0F766E; background: #ECFDF5;
  border-left: 3px solid #0F766E; padding: 6px 10px; border-radius: 0 6px 6px 0;
}
.flow-ctrl { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.flow-pos { font-size: 12.5px; color: var(--muted); }
