:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1f2733;
  --muted: #6b7686;
  --line: #e4e8f0;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --warn: #dc2626;
  --ok: #16a34a;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}

.hidden { display: none !important; }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  background: var(--brand);
  color: #fff;
  font-weight: 500;
  transition: background .15s ease;
}
button:hover { background: var(--brand-dark); }
button:disabled { opacity: .55; cursor: not-allowed; }

.btn-ghost {
  background: #eef1f7;
  color: var(--ink);
}
.btn-ghost:hover { background: #e1e6ef; }
.btn-warn { background: var(--warn); }
.btn-warn:hover { background: #b91c1c; }

input, select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a, #2563eb 55%, #38bdf8);
}
.login-card {
  width: 360px;
  background: var(--panel);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, .25);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 { margin: 0; font-size: 20px; }
.login-card .subtitle { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input { font-size: 15px; }
.login-card button { margin-top: 6px; padding: 11px; font-size: 15px; }

.error-box {
  background: #fef2f2;
  color: var(--warn);
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 160px;
  overflow: auto;
}

/* ---------- 顶栏 ---------- */
.topbar {
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.brand { font-weight: 700; font-size: 17px; color: var(--brand); display: flex; align-items: center; gap: 10px; }
.brand span { color: var(--ink); font-weight: 600; margin-left: 4px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-badge { color: var(--muted); font-size: 13px; }

/* ---------- 标签页 ---------- */
.modswitch {
  display: flex;
  gap: 8px;
  padding: 14px 20px 0;
}
.modbtn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 18px;
  font-weight: 600;
}
.modbtn:hover { background: #e9edf5; color: var(--ink); }
.modbtn.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.tabs {
  display: flex;
  gap: 4px;
  padding: 12px 20px 0;
}
.tab {
  background: transparent;
  color: var(--muted);
  border-radius: 8px 8px 0 0;
  padding: 9px 18px;
  font-weight: 500;
}
.tab:hover { background: #e9edf5; color: var(--ink); }
.tab.active { background: var(--panel); color: var(--brand); box-shadow: var(--shadow); }

main { padding: 16px 20px 40px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters input { width: 150px; }
.filters .divider { width: 1px; height: 24px; background: var(--line); }

.status { color: var(--muted); font-size: 13px; margin: 4px 2px 10px; min-height: 18px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  white-space: nowrap;
}
th { background: #f8fafc; color: var(--muted); font-weight: 600; position: sticky; top: 0; }
tbody tr:hover { background: #f5f8ff; }
.row-link { color: var(--brand); cursor: pointer; }

.pager { display: flex; align-items: center; gap: 14px; justify-content: center; margin-top: 6px; }
#page-info { color: var(--muted); }

/* ---------- 新建表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; }
.form-grid.g3 { grid-template-columns: repeat(3, 1fr); }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.form-grid .span2 { grid-column: span 2; }
.form-grid .span3 { grid-column: span 3; }
.form-grid .span1 { grid-column: span 1; flex-direction: row; align-items: center; }
.section-title { border-left: 3px solid var(--brand); padding-left: 8px; }
.hint { color: var(--muted); font-size: 12px; font-weight: 400; }
input[readonly] { background: #f3f5f9; color: var(--muted); }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; }
h3 { display: flex; align-items: center; gap: 12px; font-size: 15px; margin: 18px 0 10px; }
#c-detail-table input { width: 100%; min-width: 90px; }
.create-actions { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.create-actions .grow, .modal-actions .grow { flex: 1; }
.total { font-weight: 600; }
.checkbox { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.checkbox input { width: auto; }

.result-box, .json-box {
  background: #0f172a;
  color: #d7e0f0;
  border-radius: 8px;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 420px;
  overflow: auto;
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}
.modal-card {
  background: var(--panel);
  border-radius: 14px;
  width: min(900px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-actions {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  align-items: center;
}

/* 物资选择弹窗 */
.modal-card.picker { width: min(1000px, 96vw); }
.modal-card.picker.wide { width: min(1180px, 97vw); }
.muted { color: var(--muted); font-size: 12px; }
.form-grid label.checkbox-field { flex-direction: row; align-items: center; gap: 10px; }
.form-grid label.checkbox-field .inline { display: inline-flex; align-items: center; gap: 8px; }
.picker-body { display: flex; min-height: 420px; max-height: 70vh; }
.picker-tree {
  width: 280px;
  border-right: 1px solid var(--line);
  overflow: auto;
  padding: 10px 8px;
}
.picker-tree ul { list-style: none; margin: 0; padding-left: 14px; }
.picker-tree > ul { padding-left: 0; }
.picker-tree li { margin: 1px 0; }
.tree-node {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}
.tree-node:hover { background: #eef3ff; }
.tree-node.active { background: var(--brand); color: #fff; }
.tree-toggle { width: 14px; display: inline-block; text-align: center; color: var(--muted); }
.tree-node.active .tree-toggle { color: #fff; }
.picker-right { flex: 1; display: flex; flex-direction: column; padding: 12px; overflow: hidden; }
.picker-results { flex: 1; overflow: auto; margin-top: 8px; }

.kv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 18px; margin-bottom: 16px; }
.kv div { font-size: 13px; }
.kv .k { color: var(--muted); margin-bottom: 2px; }
.kv .v { font-weight: 500; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  z-index: 100;
  max-width: 80vw;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--warn); }

.cls-path {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #555;
  font-size: 12px;
}

.attach-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
}
.attach-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  background: #f5f7fa;
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}
.attach-list li.upload-item {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.upload-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.upload-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.upload-state { color: var(--muted); font-size: 12px; white-space: nowrap; }
.upload-state.err { color: #c0392b; }
.progress {
  height: 6px;
  background: #e3e8ef;
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: var(--brand);
  border-radius: 999px;
  transition: width 0.15s ease;
}
.progress-bar.indeterminate {
  width: 40% !important;
  animation: progress-slide 1s linear infinite;
}
@keyframes progress-slide {
  0% { margin-left: -40%; }
  100% { margin-left: 100%; }
}

/* ---------- 详情整页 ---------- */
.badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  background: #eef2fb;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
}
.subtabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.subtab {
  background: transparent;
  color: var(--muted);
  border-radius: 6px 6px 0 0;
  padding: 8px 16px;
  font-weight: 500;
}
.subtab:hover { background: #eef1f6; color: var(--ink); }
.subtab.active { color: var(--brand); border-bottom: 2px solid var(--brand); }
.subpanel { display: none; }
.subpanel.active { display: block; }

/* ---------- 编辑模式提示条 ---------- */
.edit-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff7e6;
  border: 1px solid #ffe0a3;
  color: #92610a;
  border-radius: 8px;
  padding: 8px 14px;
  margin-bottom: 14px;
  font-size: 13px;
}
.grow { flex: 1; }
