:root {
  --primary: #1f4e79;
  --primary-2: #2e6da4;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

.hidden { display: none !important; }

/* 登录 */
.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1f4e79, #2e6da4 60%, #3f8ac0);
}
.login-card {
  width: 340px;
  background: #fff;
  padding: 28px;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; color: var(--primary); }
.login-card label { display: block; margin-top: 14px; }
.login-card button { width: 100%; margin-top: 18px; }

/* 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 22px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
}
.brand { font-size: 17px; font-weight: 700; letter-spacing: 1px; }
.top-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #fff;
  padding: 2px;
  object-fit: contain;
  flex: 0 0 auto;
}
.login-logo {
  display: block;
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  border-radius: 16px;
  background: #fff;
  padding: 4px;
  object-fit: contain;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .15);
}
.logo-preview { margin: 10px 0 16px; }
.logo-preview img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
}
#nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
#nav button {
  border: 0;
  background: transparent;
  color: #dbeafe;
  padding: 7px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
}
#nav button:hover { background: rgba(255, 255, 255, .12); }
#nav button.active { background: #fff; color: var(--primary); font-weight: 700; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 13px; white-space: nowrap; }
.userbox .ghost { color: #fff; border-color: rgba(255, 255, 255, .5); }

main { max-width: 1220px; margin: 0 auto; padding: 20px; }
.tab { display: none; }
.tab.active { display: block; }

/* 卡片与面板 */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px 18px;
  border: 1px solid var(--line);
}
.card .label { color: var(--muted); font-size: 13px; }
.card .value { font-size: 26px; font-weight: 700; color: var(--primary); margin-top: 4px; }
.card .sub { font-size: 12px; color: var(--muted); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.panel h3 { margin: 0 0 12px; font-size: 16px; color: var(--primary); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.muted { color: var(--muted); font-size: 12px; }
.error { color: var(--danger); min-height: 20px; }

/* 表单 */
label { display: block; margin: 10px 0; font-size: 13px; color: #374151; }
input, select, textarea {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  font: inherit;
  background: #fff;
}
textarea { resize: vertical; min-height: 58px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary-2); }

button {
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: #e5e7eb;
  color: #111827;
  cursor: pointer;
  font: inherit;
}
button:hover { filter: brightness(.97); }
button.primary { background: var(--primary-2); color: #fff; }
button.danger { background: var(--danger); color: #fff; }
button.ghost { background: transparent; border-color: #cbd5e1; }
button.tiny { padding: 2px 8px; font-size: 12px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input, .toolbar select { width: auto; min-width: 130px; margin-top: 0; }

.formgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 14px; }
.formgrid .wide { grid-column: span 2; }
.addbox { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 8px; }
.addbox summary { cursor: pointer; color: var(--primary-2); margin-bottom: 6px; }

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f1f5f9; color: #334155; font-weight: 700; white-space: nowrap; }
tbody tr:hover { background: #f8fafc; }
.table-wrap { overflow-x: auto; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 12px; }
.tag.in { background: #dcfce7; color: var(--ok); }
.tag.out { background: #fee2e2; color: var(--danger); }
.tag.rev { background: #fef3c7; color: var(--warn); }

.reply {
  margin-top: 14px;
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px;
  border-radius: 8px;
  white-space: pre-wrap;
  min-height: 44px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #111827;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .3);
  z-index: 99;
  max-width: 420px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, .45);
}
.modal-card {
  width: 420px;
  max-width: 100%;
  background: #fff;
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .3);
}
.modal-card h3 { margin: 0 0 8px; color: var(--primary); }
.modal-card.wide { width: 680px; }
.op button { margin: 1px 2px; }

.site-footer {
  padding: 18px 20px 22px;
  text-align: center;
  color: #94a3b8;
  font-size: 12px;
}
.site-footer a { color: #94a3b8; text-decoration: none; }
.site-footer a:hover { color: #64748b; text-decoration: underline; }

@media (max-width: 900px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .formgrid { grid-template-columns: 1fr 1fr; }
  .topbar { flex-wrap: wrap; }
  .brand { width: 100%; }
}
