* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --g: #07c160;
  --g-d: #059669;
  --ink: #111827;
  --ink2: #4b5563;
  --ink3: #9ca3af;
  --line: #e5e7eb;
  --bg: #f6f7f9;
  --card: #fff;
  --red: #dc2626;
  --amber: #d97706;
  --blue: #2563eb;
  --side: #111827;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ---------------- 登录 ---------------- */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1000px 500px at 20% 0%, #12351f 0%, #0b1220 55%, #070b14 100%);
  padding: 20px;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: #fff;
  border-radius: 18px;
  padding: 28px 24px 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
  text-align: center;
}
.auth-logo {
  width: 52px; height: 52px; margin: 0 auto 14px;
  border-radius: 15px;
  background: linear-gradient(135deg, #07c160, #039b74);
  color: #fff; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 22px rgba(7, 193, 96, .3);
  padding-left: 2px;
}
.auth-card h1 { font-size: 20px; }
.auth-sub { font-size: 12.5px; color: var(--ink3); margin: 5px 0 18px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.auth-form label { font-size: 12.5px; font-weight: 600; display: flex; flex-direction: column; gap: 6px; }
.auth-form input, .field input, .field select, .field textarea {
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  background: #fff;
  transition: all .2s;
  font-size: 13.5px;
}
.auth-form input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--g);
  box-shadow: 0 0 0 3px rgba(7, 193, 96, .12);
}
.abtn {
  border: none; border-radius: 10px; padding: 11px 16px;
  font-size: 14px; font-weight: 600;
}
.abtn.primary { background: linear-gradient(135deg, #07c160, #039b74); color: #fff; }
.abtn.primary:hover { filter: brightness(1.04); }
.abtn:disabled { opacity: .6; cursor: not-allowed; }
.auth-tip { font-size: 11.5px; color: var(--ink3); margin-top: 12px; min-height: 16px; }
.auth-back { display: inline-block; margin-top: 14px; font-size: 11.5px; color: var(--ink3); }
.auth-back:hover { color: var(--g-d); }

/* ---------------- 骨架 ---------------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 224px; flex-shrink: 0;
  background: var(--side);
  color: #cbd5e1;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px;
  font-weight: 700; color: #fff; font-size: 14.5px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.sb-logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: rgba(7, 193, 96, .18);
  border: 1px solid rgba(7, 193, 96, .35);
  color: #34d399; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  padding-left: 1px;
}
.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 13px;
  color: #a8b3c4;
  transition: all .18s;
}
.nav a i { font-style: normal; font-size: 14px; opacity: .85; width: 18px; text-align: center; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.on { background: rgba(7, 193, 96, .16); color: #34d399; font-weight: 600; }
.side-foot {
  padding: 14px 18px;
  border-top: 1px solid rgba(255, 255, 255, .07);
  display: flex; justify-content: space-between;
  font-size: 11px; color: #6b7280;
}
.side-foot a:hover { color: #34d399; }

.body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; flex-shrink: 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
  padding: 0 22px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 16px; font-weight: 700; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { font-size: 12px; color: var(--ink2); background: #f3f4f6; padding: 5px 11px; border-radius: 999px; }
.tbtn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 12px; font-size: 12px; color: var(--ink2); }
.tbtn:hover { border-color: #d1d5db; background: #fafafa; }
.menu-btn { display: none; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 5px 10px; }

.view { padding: 22px; max-width: 1320px; width: 100%; }

/* ---------------- 通用块 ---------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { font-size: 14.5px; font-weight: 700; }
.card-head .sub { font-size: 11.5px; color: var(--ink3); }
.card-head .right { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  display: inline-flex; align-items: center; gap: 5px;
  transition: all .18s;
}
.btn:hover { background: #f9fafb; border-color: #d1d5db; }
.btn.primary { background: linear-gradient(135deg, #07c160, #039b74); border-color: transparent; color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--red); border-color: #fecaca; background: #fff; }
.btn.danger:hover { background: #fef2f2; }
.btn.ghost { background: #f3f4f6; border-color: transparent; }
.btn.sm { padding: 4px 9px; font-size: 11.5px; border-radius: 7px; }
.btn.link { border: none; background: none; padding: 2px 5px; color: var(--blue); font-size: 12px; }
.btn.link.red { color: var(--red); }

.grid { display: grid; gap: 14px; }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }

.stat {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 16px;
}
.stat .lab { font-size: 12px; color: var(--ink3); display: flex; align-items: center; gap: 6px; }
.stat .num { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.stat .hint { font-size: 11px; color: var(--ink3); margin-top: 3px; }
.stat.green .num { color: var(--g-d); }
.stat.amber .num { color: var(--amber); }
.stat.red .num { color: var(--red); }

/* 柱状图 */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding: 6px 2px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar {
  width: 100%; max-width: 46px;
  background: linear-gradient(180deg, #34d399, #07c160);
  border-radius: 6px 6px 3px 3px;
  min-height: 3px;
  position: relative;
  transition: height .4s;
}
.bar span {
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
  font-size: 10px; color: var(--ink2); white-space: nowrap;
}
.bar-col em { font-style: normal; font-size: 10.5px; color: var(--ink3); }

/* ---------------- 表格 ---------------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 680px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #f1f2f4; vertical-align: middle; }
th { background: #fafbfc; font-size: 11.5px; font-weight: 600; color: var(--ink2); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafcfa; }
td.num, th.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; }
.ellip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }
.muted { color: var(--ink3); }
.actions { display: flex; gap: 2px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 600;
  background: #f3f4f6; color: var(--ink2);
  white-space: nowrap;
}
.chip.green { background: #ecfdf5; color: #047857; }
.chip.red { background: #fef2f2; color: #b91c1c; }
.chip.amber { background: #fffbeb; color: #b45309; }
.chip.blue { background: #eff6ff; color: #1d4ed8; }
.chip.gray { background: #f3f4f6; color: #6b7280; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select {
  border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 11px; font-size: 12.5px; outline: none; background: #fff;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--g); }
.toolbar .grow { flex: 1; min-width: 140px; }

.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 12px; font-size: 12px; color: var(--ink3); }

/* ---------------- 表单 ---------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 11.5px; font-weight: 600; color: var(--ink2); }
.field .tip { font-size: 10.5px; color: var(--ink3); }
.field textarea { min-height: 70px; resize: vertical; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid #f1f2f4;
}
.switch-row:last-child { border-bottom: none; }
.switch-row .t { font-size: 12.5px; font-weight: 600; }
.switch-row .d { font-size: 11px; color: var(--ink3); margin-top: 1px; }

.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; background: #d1d5db; border-radius: 999px; transition: .2s; cursor: pointer;
}
.switch span::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + span { background: var(--g); }
.switch input:checked + span::before { transform: translateX(18px); }

.feat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.feat-item {
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; cursor: pointer;
  background: #fff;
}
.feat-item:hover { border-color: #d1d5db; }
.feat-item input { accent-color: var(--g); }
.feat-item.on { border-color: #a7f3d0; background: #f6fef9; }

.seg { display: flex; background: #f3f4f6; border-radius: 9px; padding: 3px; }
.seg button { border: none; background: transparent; padding: 6px 14px; border-radius: 7px; font-size: 12px; color: var(--ink2); }
.seg button.on { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08); font-weight: 600; color: var(--ink); }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .45);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
}
.modal {
  background: #fff; border-radius: 16px;
  width: 100%; max-width: 460px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 30px 70px rgba(0,0,0,.3);
  animation: pop .2s ease;
}
.modal-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-body { overflow-y: auto; flex: 1; min-height: 0; }
.modal.wide { max-width: 640px; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); font-size: 15px; font-weight: 700; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

/* ---------------- Toast ---------------- */
.toasts {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: rgba(17, 24, 39, .94); color: #fff;
  padding: 9px 16px; border-radius: 9px;
  font-size: 12.5px; box-shadow: 0 10px 30px rgba(0,0,0,.2);
  opacity: 0; transform: translateY(-8px); transition: .25s;
}
.toast.show { opacity: 1; transform: none; }
.toast.ok { background: #065f46; }
.toast.err { background: #991b1b; }
.toast.warn { background: #92400e; }

.loading-block { padding: 40px; text-align: center; color: var(--ink3); font-size: 13px; }
.spin {
  width: 26px; height: 26px; margin: 0 auto 10px;
  border: 3px solid #e5e7eb; border-top-color: var(--g);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty { padding: 34px; text-align: center; color: var(--ink3); font-size: 12.5px; }
.code-box {
  display: flex; flex-wrap: wrap; gap: 7px;
  padding: 12px; background: #f9fafb; border: 1px dashed var(--line); border-radius: 10px;
  max-height: 220px; overflow-y: auto;
}
.code-pill {
  font-family: ui-monospace, monospace; font-size: 12px;
  background: #fff; border: 1px solid var(--line);
  padding: 5px 9px; border-radius: 7px; user-select: all;
}

@media (max-width: 900px) {
  .grid.c4 { grid-template-columns: repeat(2, 1fr); }
  .grid.c3 { grid-template-columns: repeat(2, 1fr); }
  .side { position: fixed; left: -240px; z-index: 50; transition: left .25s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .side.open { left: 0; }
  .menu-btn { display: block; }
  .form-grid { grid-template-columns: 1fr; }
  .feat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .grid.c4, .grid.c3, .grid.c2 { grid-template-columns: 1fr; }
  .view { padding: 14px; }
  .topbar { padding: 0 14px; }
  .feat-grid { grid-template-columns: 1fr; }
}
