/* 慧校宝 - 校园官方淡蓝主题 */
:root {
  --primary: #3a7fc1;
  --primary-light: #5b9bd5;
  --primary-dark: #2b6aa3;
  --primary-bg: #e8f2fb;
  --primary-soft: #f0f7fc;
  --white: #ffffff;
  --gray-50: #f7f9fc;
  --gray-100: #eef2f7;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-500: #64748b;
  --gray-700: #334155;
  --gray-900: #1e293b;
  --success: #2f9e6e;
  --warning: #d48806;
  --danger: #c94c4c;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(42, 90, 140, 0.06);
  --shadow-md: 0 4px 20px rgba(42, 90, 140, 0.08);
  --sidebar-w: 240px;
  --top-h: 56px;
  --font: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: var(--font); background: var(--gray-50); color: var(--gray-900); font-size: 14px; line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }

/* Layout */
.app-wrap { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: linear-gradient(180deg, #2f6fad 0%, #3a7fc1 55%, #4a8ec9 100%);
  color: #fff; position: fixed; left: 0; top: 0; bottom: 0; z-index: 100; overflow-y: auto;
  transition: transform .25s ease;
}
.sidebar-brand {
  height: var(--top-h); display: flex; align-items: center; padding: 0 20px;
  font-size: 18px; font-weight: 700; letter-spacing: 1px; border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-brand i { margin-right: 10px; font-size: 22px; }
.sidebar-nav { padding: 12px 10px 40px; }
.nav-group { margin-top: 10px; }
.nav-group-title {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 14px; font-weight: 600; letter-spacing: .2px; color: rgba(255,255,255,.9);
  padding: 10px 14px; margin: 0; border: 0; border-radius: 8px; background: transparent;
  cursor: pointer; text-align: left; font-family: inherit; line-height: 1.6;
}
.nav-group-title:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-group-caret { font-size: 10px; opacity: .7; transition: transform .2s ease; }
.nav-group.is-open > .nav-group-title .nav-group-caret { transform: rotate(180deg); }
.nav-group-body {
  display: none; padding: 2px 0 4px;
}
.nav-group.is-open > .nav-group-body { display: block; }
.nav-group.has-active > .nav-group-title { color: #fff; }
.nav-item {
  display: flex; align-items: center; padding: 10px 14px; margin: 2px 0; border-radius: 8px;
  color: rgba(255,255,255,.9); transition: background .15s;
}
.nav-item i { width: 22px; margin-right: 10px; text-align: center; opacity: .9; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.16); color: #fff; }

.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--top-h); background: var(--white); border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
  position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.menu-toggle {
  display: none; border: none; background: var(--primary-bg); color: var(--primary);
  width: 36px; height: 36px; border-radius: 8px; cursor: pointer;
}
.page-title { font-size: 16px; font-weight: 600; color: var(--gray-700); margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 16px; color: var(--gray-500); }
.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 20px;
  background: var(--primary-soft); color: var(--primary-dark); font-size: 13px;
}

.content { padding: 20px; flex: 1; }

/* Cards */
.card {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--gray-100); margin-bottom: 16px;
}
.card-header {
  padding: 14px 18px; border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.card-header h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--gray-700); }
.card-body { padding: 18px; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat-card {
  background: var(--white); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  border: 1px solid var(--gray-100); position: relative; overflow: hidden;
}
.stat-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary);
}
.stat-label { color: var(--gray-500); font-size: 13px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--primary-dark); margin-top: 6px; }
.stat-sub { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* Forms */
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 6px; color: var(--gray-700); font-weight: 500; font-size: 13px; }
.form-control {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--gray-200); border-radius: 8px;
  background: #fff; color: var(--gray-900); outline: none; transition: border .15s, box-shadow .15s;
}
.form-control:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(58,127,193,.12); }
textarea.form-control { height: auto; padding: 10px 12px; min-height: 90px; }
select.form-control { appearance: auto; }
.form-hint { font-size: 12px; color: var(--gray-500); margin-top: 4px; }
.form-error { color: var(--danger); font-size: 12px; margin-top: 4px; display: none; }
.form-group.has-error .form-control { border-color: var(--danger); }
.form-group.has-error .form-error { display: block; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: 8px; border: 1px solid transparent;
  font-size: 13px; cursor: pointer; transition: all .15s; font-family: inherit; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-outline { background: #fff; border-color: var(--gray-200); color: var(--gray-700); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* Table */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 12px; border-bottom: 1px solid var(--gray-100); text-align: left; white-space: nowrap; }
.table th { background: var(--primary-soft); color: var(--gray-700); font-weight: 600; font-size: 13px; }
.table tr:hover td { background: #fafcfe; }
.table .empty { text-align: center; color: var(--gray-500); padding: 40px; white-space: normal; }

/* Badge */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 500;
}
.badge-primary { background: var(--primary-bg); color: var(--primary-dark); }
.badge-success { background: #e6f6ee; color: var(--success); }
.badge-warning { background: #fff7e6; color: var(--warning); }
.badge-danger { background: #fdecea; color: var(--danger); }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }

/* Toolbar / filter */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .form-control { width: auto; min-width: 140px; height: 34px; }

/* Pagination */
.pagination { display: flex; gap: 6px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px;
  padding: 0 8px; border-radius: 6px; border: 1px solid var(--gray-200); color: var(--gray-700); background: #fff;
}
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Modal */
.modal-mask {
  position: fixed; inset: 0; background: rgba(30,41,59,.45); z-index: 200; display: none;
  align-items: center; justify-content: center; padding: 16px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto;
  box-shadow: var(--shadow-md); animation: modalIn .2s ease;
}
.modal-xl { max-width: 1100px; width: 96%; }
.receipt-editor-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) {
  .receipt-editor-layout { grid-template-columns: 1fr; }
}
.receipt-toolbar {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 8px; background: #f7f9fc; border: 1px solid var(--gray-200);
  border-bottom: none; border-radius: 8px 8px 0 0;
}
.receipt-toolbar .btn { padding: 4px 10px; }
.receipt-toolbar select { height: 30px; font-size: 12px; max-width: 160px; }
.receipt-editor {
  min-height: 360px; max-height: 520px; overflow: auto;
  padding: 20px; background: #fff;
  border: 1px solid var(--gray-200); border-radius: 0 0 8px 8px;
  outline: none; line-height: 1.7; font-family: "SimSun","Microsoft YaHei",serif;
  font-size: 14px; color: #222;
}
.receipt-editor:focus { box-shadow: inset 0 0 0 2px rgba(58,127,193,.15); }
.receipt-editor .tpl-var {
  display: inline-block; padding: 0 6px; margin: 0 1px;
  background: #e8f2fb; color: #2b6aa3; border: 1px solid #b7d4ef;
  border-radius: 4px; font-family: Consolas, monospace; font-size: 12px;
  cursor: default; user-select: none; white-space: nowrap;
}
.receipt-preview-pane {
  background: #eef2f7; border-radius: 8px; padding: 12px;
  border: 1px solid var(--gray-200); min-height: 360px;
}
.receipt-preview-pane h5 {
  margin: 0 0 10px; font-size: 13px; color: var(--gray-500); font-weight: 600;
}
.receipt-preview-paper {
  background: #fff; border-radius: 8px; padding: 16px;
  box-shadow: 0 2px 10px rgba(42,90,140,.08); min-height: 300px;
  max-height: 520px; overflow: auto;
}
.preset-chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.preset-chip-row .btn { font-size: 12px; }

.modal-header { padding: 16px 18px; border-bottom: 1px solid var(--gray-100); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-close { border: none; background: transparent; font-size: 20px; cursor: pointer; color: var(--gray-500); }
.modal-body { padding: 18px; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--gray-100); display: flex; justify-content: flex-end; gap: 8px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Toast */
.toast-wrap {
  position: fixed; top: 20px; right: 20px; left: auto; transform: none;
  z-index: 99999; display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  min-width: 220px; max-width: 360px; padding: 12px 16px; border-radius: 8px; color: #fff;
  box-shadow: var(--shadow-md); animation: modalIn .2s ease; font-size: 13px;
  pointer-events: auto; word-break: break-word;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

/* Loading */
.loading-mask {
  position: fixed; inset: 0; background: rgba(255,255,255,.55); z-index: 99990; display: none;
  align-items: center; justify-content: center;
}
.loading-mask.show { display: flex; }
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--primary-bg); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #e8f2fb 0%, #f7f9fc 45%, #dceaf7 100%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 420px; background: #fff; border-radius: 14px; padding: 36px 32px;
  box-shadow: var(--shadow-md); border: 1px solid var(--gray-100);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand .logo {
  width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 26px;
}
.login-brand h1 { margin: 0; font-size: 22px; color: var(--primary-dark); }
.login-brand p { margin: 6px 0 0; color: var(--gray-500); font-size: 13px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-box { height: 280px; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--gray-500); }
.empty-state i { font-size: 42px; color: var(--gray-300); margin-bottom: 10px; display: block; }

.sidebar-mask { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 90; }

/* Responsive */
@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-mask.show { display: block; }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .content { padding: 14px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 22px; }
  .toolbar .form-control { min-width: 100%; width: 100%; }
  .card-header { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
}
