* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #3b82f6 100%);
  position: relative;
}
.login-card {
  width: 400px; max-width: 92vw; background: #fff; border-radius: 16px;
  padding: 36px 36px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.login-logo {
  width: 50px; height: 50px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, #2563eb, #1e40af); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; box-shadow: 0 4px 12px rgba(37,99,235,.35);
}
.login-title { font-size: 22px; font-weight: 700; letter-spacing: 1px; }
.login-subtitle { font-size: 13px; color: var(--muted); margin-top: 3px; }
.login-tabs { display: flex; border-bottom: 2px solid var(--line); margin-bottom: 22px; }
.login-tab {
  flex: 1; padding: 10px 0; border: none; background: none; cursor: pointer;
  font-size: 15px; color: var(--muted); font-weight: 600; position: relative;
}
.login-tab.active { color: var(--primary); }
.login-tab.active::after {
  content: ''; position: absolute; left: 20%; right: 20%; bottom: -2px;
  height: 2px; background: var(--primary); border-radius: 2px;
}
.field-label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: #334155; }
.field-input {
  width: 100%; padding: 11px 13px; border: 1px solid #cbd5e1; border-radius: 8px;
  font-size: 14px; outline: none; transition: border .15s, box-shadow .15s;
}
.field-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.login-err { color: var(--err); font-size: 13px; min-height: 20px; margin-top: 10px; }
.btn-primary {
  background: var(--primary); color: #fff; border: none; border-radius: 8px;
  cursor: pointer; font-weight: 600; transition: background .15s;
}
.btn-primary:hover { background: var(--primary-d); }
.btn-primary:disabled { background: #93c5fd; cursor: not-allowed; }
.login-btn { width: 100%; padding: 12px; font-size: 16px; margin-top: 4px; }
.login-hint { text-align: center; color: #94a3b8; font-size: 12px; margin-top: 16px; line-height: 1.6; }
.login-footer { color: rgba(255,255,255,.6); font-size: 12px; margin-top: 22px; }

/* ---------- 应用布局 ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 230px; flex: none; background: #0f172a; color: #cbd5e1;
  display: flex; flex-direction: column;
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 20px; border-bottom: 1px solid #1e293b; }
.side-logo {
  width: 38px; height: 38px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, #2563eb, #1e40af); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700;
}
.side-title { color: #fff; font-size: 16px; font-weight: 700; }
.side-sub { font-size: 11px; color: #64748b; margin-top: 2px; }
.side-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 20px; cursor: pointer;
  font-size: 14px; color: #94a3b8; border-left: 3px solid transparent; transition: all .15s;
}
.nav-item:hover { background: #1e293b; color: #e2e8f0; }
.nav-item.active { background: #1e293b; color: #fff; border-left-color: #3b82f6; font-weight: 600; }
.nav-icon { width: 20px; text-align: center; font-size: 16px; }
.side-bottom { border-top: 1px solid #1e293b; padding: 14px 20px; }
.side-user { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: #334155; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600;
}
.user-name { color: #e2e8f0; font-size: 13px; font-weight: 600; }
.user-role { color: #64748b; font-size: 11px; margin-top: 2px; }
.logout-btn {
  width: 100%; margin-top: 12px; padding: 8px; background: #1e293b; color: #94a3b8;
  border: 1px solid #334155; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.logout-btn:hover { color: #fff; background: #334155; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; flex: none; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 28px;
}
.crumb { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.dot-live { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
.topbar-divider { width: 1px; height: 16px; background: var(--line); margin: 0 6px; }
.content { flex: 1; overflow-y: auto; padding: 24px 28px 40px; }

/* ---------- 通用组件 ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-title { font-size: 18px; font-weight: 700; }
.page-desc { font-size: 13px; color: var(--muted); margin-top: 4px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { background: var(--card); border-radius: 12px; padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.stat-label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.stat-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 12px; letter-spacing: -.5px; }
.stat-foot { font-size: 12px; color: #94a3b8; margin-top: 6px; }

.panel { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); margin-bottom: 20px; overflow: hidden; }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.panel-title { font-size: 15px; font-weight: 700; }
.panel-body { padding: 4px 0; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 20px; font-size: 13px; }
th { color: var(--muted); font-weight: 600; background: #f8fafc; border-bottom: 1px solid var(--line); }
td { border-bottom: 1px solid #f1f5f9; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-err { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: #475569; }
.money { font-weight: 600; }
.empty { padding: 48px 20px; text-align: center; color: #94a3b8; }
.empty-icon { font-size: 40px; opacity: .5; margin-bottom: 10px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar select, .toolbar input {
  padding: 8px 11px; border: 1px solid #cbd5e1; border-radius: 7px; font-size: 13px; outline: none; background: #fff;
}
.toolbar .btn-sm { padding: 8px 16px; font-size: 13px; border-radius: 7px; }

.form-panel { max-width: 520px; }
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #334155; }
.form-row input, .form-row select {
  width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; outline: none;
}
.form-row input:focus, .form-row select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.btn-sm { padding: 8px 16px; font-size: 13px; border-radius: 7px; }
.btn-ghost { background: #f1f5f9; color: #475569; border: 1px solid var(--line); cursor: pointer; }
.btn-ghost:hover { background: #e2e8f0; }
.note { font-size: 12px; color: var(--muted); background: #f8fafc; border-left: 3px solid #cbd5e1; padding: 10px 14px; border-radius: 0 6px 6px 0; line-height: 1.7; margin-top: 14px; }

.loading { padding: 40px; text-align: center; color: var(--muted); }
.spinner { display: inline-block; width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; top: 22px; left: 50%; transform: translateX(-50%); z-index: 999;
  padding: 12px 22px; border-radius: 8px; color: #fff; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.toast-ok { background: var(--ok); }
.toast-err { background: var(--err); }

@media (max-width: 760px) {
  .sidebar { width: 68px; }
  .side-brand > div:last-child, .side-title, .side-sub, .nav-item span:not(.nav-icon), .side-user > div:not(.avatar), .user-name, .user-role, .logout-btn { display: none; }
  .nav-item { justify-content: center; padding: 12px 0; }
  .content { padding: 16px; }
}
