/* 农小宝智能财税实训系统 - 正式管理后台风格 */
:root {
  --primary: #1d4f91;
  --primary-hover: #163f75;
  --primary-light: #e8eef7;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1f2329;
  --muted: #646a73;
  --line: #dcdfe6;
  --success: #2e7d32;
  --warning: #d48806;
  --error: #c0392b;
  --radius: 4px;
  --shadow: 0 1px 2px rgba(0,0,0,.06);
  --font: PingFang SC, Microsoft YaHei, Hiragino Sans GB, Noto Sans CJK SC, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 12px; line-height: 1.3; }
h1 { font-size: 20px; font-weight: 600; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0 0 10px; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 56px; z-index: 40;
  display: flex; align-items: center; gap: 10px; padding: 0 20px;
  background: #1f3a5f; color: #fff;
}
.topbar-logo { display: inline-flex; }
.topbar-logo svg { width: 30px; height: 30px; display: block; }
.topbar .brand-name { color: #fff; font-size: 16px; font-weight: 600; letter-spacing: .5px; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.topbar-user { font-size: 13px; color: rgba(255,255,255,.85); white-space: nowrap; }
.topbar-logout {
  font-size: 13px; color: #fff; padding: 4px 10px; border: 1px solid rgba(255,255,255,.35); border-radius: var(--radius);
  white-space: nowrap;
}
.topbar-logout:hover { background: rgba(255,255,255,.1); }
.body { display: flex; padding-top: 56px; min-height: 100vh; }
.sidebar {
  position: fixed; top: 56px; bottom: 0; left: 0; width: 200px; z-index: 30;
  background: #fff; border-right: 1px solid var(--line); overflow-y: auto;
}
.nav { padding: 10px 0; display: flex; flex-direction: column; }
.nav a {
  color: var(--text); padding: 10px 18px; display: flex; align-items: center; gap: 10px;
  border-left: 3px solid transparent; font-size: 14px;
}
.nav a .ico { width: 18px; height: 18px; flex: 0 0 18px; display: inline-flex; }
.nav a .ico svg { width: 18px; height: 18px; }
.nav a:hover { background: #f5f7fa; }
.nav a.active { color: var(--primary); background: var(--primary-light); border-left-color: var(--primary); font-weight: 600; }
.content { flex: 1; min-width: 0; margin-left: 200px; padding: 20px 24px 40px; }
.tabbar { display: none; }

@media (max-width: 767px) {
  .topbar { padding: 0 12px; gap: 8px; height: 50px; }
  .topbar-logo svg { width: 26px; height: 26px; }
  .topbar .brand-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
  .topbar-user { display: none; }
  .topbar-logout { padding: 3px 8px; font-size: 12px; }
  .body { padding-top: 50px; }
  .sidebar { display: none; }
  .content { margin-left: 0; padding: 14px 12px 88px; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line);
    z-index: 30; padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    flex: 1; text-align: center; padding: 7px 2px 6px; font-size: 11px; color: var(--muted);
    display: flex; flex-direction: column; align-items: center; gap: 3px; white-space: nowrap;
  }
  .tabbar a .ico { display: inline-flex; }
  .tabbar a .ico svg { width: 20px; height: 20px; }
  .tabbar a.active { color: var(--primary); font-weight: 600; }
  h1 { font-size: 18px; }
}

/* ---------- components ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.page-title { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 16px; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px;
  border: 1px solid var(--line);
}
.card.flat { box-shadow: none; }

.card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.card-title h2, .card-title h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 991px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

.stat { padding: 16px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat .value small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.stat.accent { background: var(--primary); color: #fff; }
.stat.accent .label { color: rgba(255, 255, 255, 0.8); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line);
  background: #fff; color: var(--text); padding: 8px 16px; border-radius: var(--radius); cursor: pointer;
  transition: all 0.15s; white-space: nowrap; font-size: 14px; line-height: 1.2;
}
.btn:hover { background: #fafbfc; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: #fff; border: none; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.green { background: var(--success); color: #fff; border: none; }
.btn.danger { color: var(--error); border-color: var(--error); background: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--primary); }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: var(--radius); }
.btn.block { width: 100%; }

input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local],
input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px;
  background: #fff; color: var(--text); outline: none; transition: border-color 0.15s;
  font-size: 14px;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(29, 79, 145, 0.1); }
textarea { resize: vertical; min-height: 80px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 0 0 auto; }
.row.grow > * { flex: 1 1 auto; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: var(--radius); font-size: 12px; background: var(--primary-light); color: var(--primary); white-space: nowrap; }
.tag.blue { background: var(--primary-light); color: var(--primary); }
.tag.orange { background: #fef5e7; color: var(--warning); }
.tag.red { background: #ffe7e6; color: var(--error); }
.tag.gray { background: #f5f5f5; color: var(--muted); }
.ok { color: var(--success); font-weight: 700; }
.bad { color: var(--error); font-weight: 700; }

 .table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.tbl th { background: #f5f7fa; font-weight: 600; color: var(--text); white-space: nowrap; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl input[type=text], table.tbl input[type=number] { padding: 6px 8px; font-size: 13px; border-radius: var(--radius); }
table.tbl.compact td, table.tbl.compact th { padding: 7px 8px; }
.money { font-variant-numeric: tabular-nums; }
tr.matched td { background: #f0f7f1; }
tr.unmatched td { background: #fffaf0; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty .big { font-size: 32px; margin-bottom: 8px; }

.alert { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 12px; font-size: 14px; border-left: 3px solid; }
.alert.info { background: #e8eef7; color: #1d4f91; border-left-color: var(--primary); }
.alert.warn { background: #fef5e7; color: var(--warning); border-left-color: var(--warning); }
.alert.error { background: #ffe7e6; color: var(--error); border-left-color: var(--error); }
.alert.ok { background: #e8f5e9; color: var(--success); border-left-color: var(--success); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--text); padding: 6px 12px;
  border-radius: var(--radius); cursor: pointer; font-size: 13px;
}
@media (max-width: 767px) {
  .table-wrap table.tbl { min-width: 600px; }
  .table-wrap table.tbl td { white-space: nowrap; }
  .table-wrap table.tbl td:first-child { white-space: normal; min-width: 9em; }
}
.chip:hover { background: #f5f5f5; }

.badge-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-right: 6px; }

/* ---------- toast / modal ---------- */
#toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 92vw; pointer-events: none; }
@media (max-width: 767px) {
  #toasts { top: auto; bottom: 84px; left: 50%; transform: translateX(-50%); width: max-content; max-width: 92vw; }
}
.toast {
  background: #262626; color: #fff; padding: 12px 16px; border-radius: var(--radius); box-shadow: var(--shadow);
  animation: fadein 0.2s ease; font-size: 14px; max-width: 360px;
}
.toast.error { background: #c0392b; }
.toast.ok { background: var(--success); }
@keyframes fadein { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.modal-mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 90; display: flex; align-items: center;
  justify-content: center; padding: 16px;
}
.modal {
  background: #fff; border-radius: var(--radius); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); padding: 20px;
  width: 100%; max-width: 440px; animation: fadein 0.15s ease; border: 1px solid var(--line);
}
.modal.wide { max-width: 760px; max-height: 90vh; overflow-y: auto; }
.modal h3 { margin-bottom: 12px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

.spinner {
  width: 18px; height: 18px; border: 2px solid #e0e0e0; border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 24px; justify-content: center; }

/* ---------- chat ---------- */
.only-mobile { display: none; }
.chat-wrap { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; height: calc(100vh - 200px); min-height: 480px; }
.chat-list { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; }
.chat-list .list-body { flex: 1; overflow-y: auto; padding: 6px; }
.chat-list .search { padding: 10px; border-bottom: 1px solid var(--line); }
.conv {
  padding: 8px 10px; border-radius: var(--radius); cursor: pointer; display: flex; align-items: center; gap: 6px;
  margin: 2px 4px; border-left: 3px solid transparent;
}
.conv:hover { background: var(--primary-light); }
.conv.active { background: var(--primary-light); border-left-color: var(--primary); }
.conv .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.conv .x { opacity: 0; color: var(--muted); padding: 0 4px; cursor: pointer; }
.conv:hover .x { opacity: 1; }
.conv .x:hover { color: var(--error); }

.chat-main { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.chat-head .title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.messages { flex: 1; overflow-y: auto; padding: 16px; background: #fff; }
.msg { display: flex; gap: 10px; margin-bottom: 12px; align-items: flex-start; }
.msg.user { flex-direction: row-reverse; }

.avatar {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%; background: var(--primary); display: flex; align-items: center;
  justify-content: center; color: #fff; font-weight: 600; font-size: 12px;
}
.avatar.bot { background: #f0f0f0; border: 1px solid var(--line); padding: 2px; }
.avatar.bot svg { width: 100%; height: 100%; }

.bubble {
  max-width: min(680px, 84%); background: #f5f5f5; border-radius: var(--radius); padding: 10px 12px;
  box-shadow: none; overflow-wrap: anywhere; border: 1px solid var(--line);
}
.msg.user .bubble { background: var(--primary); color: #fff; border: none; white-space: pre-wrap; }
.bubble.md p:last-child, .md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3 { margin-top: 10px; }
.md table { border-collapse: collapse; margin: 8px 0; display: block; overflow-x: auto; max-width: 100%; font-size: 13px; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 8px; }
.md th { background: #f5f7fa; }
.md pre { background: #1f2329; color: #f0f0f0; padding: 10px; border-radius: var(--radius); overflow-x: auto; font-size: 12px; }
.md code { background: #f5f5f5; padding: 2px 4px; border-radius: var(--radius); font-size: 12px; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: 8px 0; padding: 6px 12px; border-left: 3px solid var(--line); color: var(--muted); background: #f9f9f9; }

.caret::after { content: ▍; color: var(--primary); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.composer { border-top: 1px solid var(--line); padding: 12px; display: flex; gap: 10px; align-items: flex-end; background: #fff; }
.composer textarea { min-height: 44px; max-height: 160px; border-radius: var(--radius); }
.composer .btn { min-width: 84px; }

.welcome { text-align: center; padding: 72px 20px 40px; color: var(--muted); }
.welcome h2 { color: var(--text); font-size: 18px; margin: 0 0 8px; }
.welcome svg { width: 80px; height: 80px; }

@media (max-width: 767px) {
  .chat-wrap { grid-template-columns: 1fr; height: calc(100vh - 140px); }
  .chat-wrap.show-list .chat-main { display: none; }
  .chat-wrap:not(.show-list) .chat-list { display: none; }
  .bubble { max-width: 90%; }
  .only-mobile { display: inline-flex; }
}

/* ---------- recon ---------- */
.recon-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 991px) { .recon-grid { grid-template-columns: minmax(0, 1fr); } }
.recon-grid > * { min-width: 0; }
.result-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 767px) { .result-cols { grid-template-columns: 1fr; } }

.balance-ok { background: #e8f5e9; color: var(--success); border-radius: var(--radius); padding: 12px 14px; font-weight: 600; border: 1px solid #c8e6c9; }
.balance-bad { background: #ffe7e6; color: var(--error); border-radius: var(--radius); padding: 12px 14px; font-weight: 600; border: 1px solid #ffcccb; }
.recon-table td input { min-width: 0; }
.cat-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; background: #f9f9f9; }

/* ---------- assignments / grading ---------- */
.q-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; background: #fff; }
.q-card .q-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.q-card .q-head .spacer { flex: 1; }
.opt { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 6px; cursor: pointer; background: #fff; }
.opt:hover { background: #f9f9f9; }
.opt input { width: auto; margin-top: 4px; }
.opt.picked { border-color: var(--primary); background: var(--primary-light); }
.opt.right { border-color: var(--success); background: #e8f5e9; }
.opt.wrong { border-color: var(--error); background: #ffe7e6; }

.qnum { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--primary); color: #fff; font-weight: 700; font-size: 12px; flex: 0 0 30px; }
.qnum.ok { background: var(--success); }
.qnum.bad { background: var(--error); }
.qnum.pend { background: var(--warning); }

.answer-line { padding: 8px 10px; border-radius: var(--radius); background: #f5f7fa; margin-top: 8px; font-size: 13px; border: 1px solid var(--line); }
.stepper { display: flex; gap: 8px; flex-wrap: wrap; }
.stepper .dot { padding: 4px 12px; border-radius: 999px; font-size: 12px; background: #f0f0f0; color: var(--muted); border: 1px solid var(--line); }
.stepper .dot.done { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.countdown { font-size: 12px; color: var(--warning); }

.chart { width: 100%; height: 300px; }
.chart.tall { height: 360px; }
.chart-card { position: relative; }
.chart-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.heat-cell { text-align: center; font-size: 11px; min-width: 48px; padding: 4px 2px; color: var(--text); }
.student-list-scroll { max-height: 420px; overflow-y: auto; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 13px; }
.kv div:nth-child(odd) { color: var(--muted); }

/* ---------- login ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: #f0f2f5;
}
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: var(--radius); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); padding: 28px; text-align: center; border: 1px solid var(--line); }
.login-card .logo svg { width: 80px; height: 80px; }
.login-card h1 { margin: 12px 0 6px; font-size: 24px; color: var(--text); }
.login-card .slogan { color: var(--muted); margin-bottom: 20px; font-size: 13px; }
.login-card form { text-align: left; }
.login-card .foot { margin-top: 14px; color: var(--muted); font-size: 12px; }

/* ---------- misc ---------- */
.pill-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.pill-tabs button {
  border: 1px solid var(--line); background: #fff; padding: 6px 14px; border-radius: var(--radius); cursor: pointer; color: var(--muted);
  transition: all 0.15s;
}
.pill-tabs button:hover { background: #f5f5f5; }
.pill-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.hr { height: 1px; background: var(--line); margin: 12px 0; border: none; }
.print-only { display: none; }
@media print {
  .sidebar, .topbar, .tabbar, .no-print { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; }
}
