:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f3f4f6;
  --sidebar-bg: #111827;
  --sidebar-text: #d1d5db;
  --sidebar-active: #2563eb;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--text); background: var(--bg); }
a { text-decoration: none; color: inherit; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#2563eb,#1e40af); }
.login-card { background: #fff; padding: 40px; border-radius: 12px; width: 360px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card .sub { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
input, select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; }
input:focus, select:focus { border-color: var(--primary); }

.btn { padding: 10px 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: .15s; background: var(--primary); color: #fff; }
.btn:hover { background: var(--primary-dark); }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 6px; }
.btn-success { background: var(--success); } .btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); } .btn-danger:hover { background: #b91c1c; }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--sidebar-bg); color: var(--sidebar-text); flex-shrink: 0; display: flex; flex-direction: column; }
.logo { padding: 20px; font-size: 17px; font-weight: 700; color: #fff; border-bottom: 1px solid #1f2937; }
.logo small { display: block; font-size: 11px; font-weight: 400; color: #9ca3af; margin-top: 3px; }
.nav { flex: 1; padding: 10px 0; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 11px 20px; cursor: pointer; font-size: 14px; transition: .15s; }
.nav-item:hover { background: #1f2937; color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-item .ic { width: 18px; text-align: center; }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid #1f2937; font-size: 12px; color: #9ca3af; }
.sidebar-foot button { background: none; border: none; color: #9ca3af; cursor: pointer; font-size: 13px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 60px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; }
.topbar .page-title { font-size: 17px; font-weight: 600; }
.topbar .user { font-size: 13px; color: var(--text-muted); }
.content { padding: 24px; flex: 1; }

/* Cards & table */
.card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 16px; }
.card h3 { font-size: 15px; margin-bottom: 14px; }
.card-row { display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 18px; }
.stat .num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat .lbl { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; font-size: 13px; border-bottom: 1px solid var(--border); }
th { background: #f9fafb; color: var(--text-muted); font-weight: 500; white-space: nowrap; }
tr:hover td { background: #fafbfc; }
.muted { color: var(--text-muted); }
.empty { text-align: center; color: var(--text-muted); padding: 30px; }

.badge { padding: 3px 8px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-yellow { background: #fef3c7; color: #b45309; }
.badge-gray { background: #f3f4f6; color: #6b7280; }
.badge-purple { background: #ede9fe; color: #6d28d9; }

.mt { margin-top: 12px; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.filter { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter input, .filter select { width: auto; min-width: 140px; }

/* Modal */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: none; align-items: center; justify-content: center; z-index: 100; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 12px; width: 480px; max-width: 94vw; padding: 24px; max-height: 86vh; overflow: auto; }
.modal h3 { margin-bottom: 18px; font-size: 16px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal textarea { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; resize: vertical; min-height: 80px; }

/* Audit special */
.audit-toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.audit-card { border: 1px solid var(--border); border-radius: 10px; background: #fff; padding: 18px; margin-bottom: 12px; }
.audit-card .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.audit-args { background: #f9fafb; border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-family: monospace; font-size: 12px; white-space: pre-wrap; word-break: break-all; margin: 10px 0; }
.audit-actions { display: flex; gap: 10px; margin-top: 10px; }

.toast { position: fixed; top: 20px; right: 20px; background: #111827; color: #fff; padding: 12px 18px; border-radius: 8px; font-size: 13px; z-index: 999; opacity: 0; transform: translateY(-10px); transition: .25s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--success); }

@media (max-width: 768px){ .layout{flex-direction:column} .sidebar{width:100%;flex-direction:row} .nav{display:flex;overflow-x:auto} .nav-item{white-space:nowrap} .sidebar-foot{display:none} }