:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #e5e8ee;
  --text: #1f2733;
  --muted: #6b7480;
  --brand: #2f6fed;
  --brand-dark: #1e56c9;
  --brand-soft: #eaf1fe;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(20, 40, 80, .08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.hidden { display: none !important; }

.layout { display: flex; height: 100vh; }

/* ---------- 侧栏 ---------- */
.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: #182232;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-icon { font-size: 22px; }

#nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 2px 0;
  border-radius: 9px;
  cursor: pointer;
  font-size: 14px;
  color: #cbd5e1;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-item .n-ico { font-size: 17px; width: 22px; text-align: center; }

.sidebar-foot {
  padding: 12px 16px;
  font-size: 12px;
  color: #64748b;
  border-top: 1px solid rgba(255,255,255,.08);
}

/* ---------- 主区 ---------- */
.main { flex: 1; overflow-y: auto; padding: 26px 30px 60px; }
.main-head h1 { margin: 0 0 6px; font-size: 24px; }
.main-head p { margin: 0 0 22px; color: var(--muted); font-size: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: #c9d6f5;
}
.card .c-ico { font-size: 26px; }
.card h3 { margin: 12px 0 6px; font-size: 16px; }
.card p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 45, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-box {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 18px; }
.close {
  border: none;
  background: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 6px;
}
.close:hover { background: #f0f2f5; color: var(--text); }

.tool-form { padding: 20px 22px; overflow-y: auto; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }

input[type=text], input[type=number], input[type=password], input[type=color],
select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d5dae3;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { min-height: 90px; resize: vertical; }

.file-drop {
  border: 2px dashed #c3ccdb;
  border-radius: 10px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.file-drop:hover, .file-drop.drag { border-color: var(--brand); background: var(--brand-soft); }
.file-drop.has { border-style: solid; border-color: #9fc0ff; color: var(--text); }
.file-drop input[type=file] { display: none; }

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

.check-line { display: flex; align-items: center; gap: 8px; }
.check-line input { width: auto; }
.check-line label { margin: 0; font-weight: 500; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 9px;
  padding: 11px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------- 结果区 ---------- */
.result {
  border-top: 1px solid var(--line);
  padding: 18px 22px;
  background: #fafbfd;
  max-height: 40vh;
  overflow-y: auto;
}
.result .r-note { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.result .r-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.result-grid img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.result pre {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 260px;
  overflow: auto;
}
.preview-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
  background: #fff;
}
.preview-table th, .preview-table td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
  white-space: nowrap;
}
.preview-table th { background: #f0f4ff; }

.download-btn {
  display: inline-block;
  background: #12b76a;
  color: #fff;
  text-decoration: none;
  padding: 10px 18px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 12px;
}
.download-btn:hover { background: #0e9c59; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2733;
  color: #fff;
  padding: 11px 20px;
  border-radius: 9px;
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast.err { background: #d73a49; }

.spin {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: rot .7s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: 0 0 auto; height: auto; }
  #nav { display: flex; overflow-x: auto; }
  .nav-item { white-space: nowrap; }
}
