* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #5b6cff;
  --primary-dark: #4453e6;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2433;
  --muted: #8a90a6;
  --border: #e7eaf3;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --shadow: 0 4px 24px rgba(80, 100, 160, .08);
}
html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  font-size: 14px;
}

button {
  cursor: pointer;
  border: none;
  background: var(--primary);
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  transition: background .15s;
}
button:hover { background: var(--primary-dark); }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.ghost:hover { background: #f0f2fa; }
button.danger { background: var(--danger); }
button.danger:hover { background: #d23434; }
button.small { padding: 4px 10px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  width: 100%;
  font-family: inherit;
  background: white;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 60px; }

.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}
.form-row .hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.form-row .hint.warn { color: var(--warning); }
.form-row .hint.error { color: var(--danger); }
.form-row .hint.success { color: var(--success); }

.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6f7eff 0%, #8b6fff 100%);
}
.login-card {
  width: 380px;
  background: white;
  border-radius: 14px;
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(50, 60, 120, .25);
}
.login-card h1 {
  font-size: 22px;
  margin-bottom: 4px;
  text-align: center;
}
.login-card .sub-title {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 26px;
  text-align: center;
}
.role-switch {
  display: flex;
  background: #f0f2fa;
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 22px;
}
.role-switch button {
  flex: 1;
  background: transparent;
  color: var(--muted);
  padding: 8px;
  border-radius: 6px;
}
.role-switch button.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
}
.role-switch button:hover { background: white; }
.login-card button.submit {
  width: 100%;
  padding: 11px;
  font-size: 15px;
  margin-top: 8px;
}
.login-tip {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: #1f2433;
  color: white;
  padding: 24px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.sidebar .brand {
  padding: 0 24px 24px;
  font-size: 18px;
  font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 14px;
}
.sidebar .brand small { display: block; font-size: 12px; color: #9aa3c0; font-weight: 400; margin-top: 2px; }
.sidebar nav { flex: 1; }
.sidebar nav a {
  display: block;
  padding: 11px 24px;
  color: #c5cae0;
  text-decoration: none;
  cursor: pointer;
  border-left: 3px solid transparent;
  font-size: 14px;
}
.sidebar nav a:hover { background: rgba(255,255,255,.04); color: white; }
.sidebar nav a.active {
  background: rgba(91, 108, 255, .12);
  border-left-color: var(--primary);
  color: white;
}
.sidebar .bottom { padding: 0 24px; color: #9aa3c0; font-size: 13px; }
.sidebar .bottom .item { padding: 8px 0; cursor: pointer; }
.sidebar .bottom .item:hover { color: white; }

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

.content { padding: 24px; flex: 1; overflow: auto; }

.card {
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card h2 {
  font-size: 16px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: white;
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}
.stat-card .label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.stat-card .value { font-size: 28px; font-weight: 600; }

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

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  background: #eef0f8;
  color: var(--muted);
}
.tag.green { background: #e6f7f0; color: var(--success); }
.tag.red { background: #fee2e2; color: var(--danger); }
.tag.blue { background: #e7eaff; color: var(--primary); }

.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar input, .toolbar select { width: auto; min-width: 200px; }
.toolbar .spacer { flex: 1; }

.pagination {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}
.pagination button { padding: 4px 12px; font-size: 13px; }

.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: white;
  border-radius: 10px;
  width: 460px;
  max-width: 92vw;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header .close { cursor: pointer; color: var(--muted); font-size: 20px; }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.modal.wide { width: 720px; }

#toast-root {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #1f2433;
  color: white;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  animation: toast-in .25s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dup-banner {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
}
.dup-banner.red {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

.import-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.import-summary > div {
  padding: 10px;
  border-radius: 6px;
  text-align: center;
}
.import-summary .ok { background: #e6f7f0; color: var(--success); }
.import-summary .dup { background: #fef3c7; color: #92400e; }
.import-summary .err { background: #fee2e2; color: var(--danger); }
.import-summary .label { font-size: 12px; }
.import-summary .value { font-size: 20px; font-weight: 600; }
.import-list {
  max-height: 240px;
  overflow: auto;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
}
.import-list .item { padding: 4px 0; border-bottom: 1px dashed var(--border); }
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-zone:hover, .upload-zone.drag {
  border-color: var(--primary);
  background: #f7f8ff;
}
.upload-zone .upload-icon { font-size: 36px; margin-bottom: 12px; }

.table-scroll {
  overflow-x: auto;
  margin: 0 -4px;
}
.table-scroll table { min-width: 900px; }
