:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --panel-alt: #f8fafc;
  --line: #dbe2ea;
  --line-strong: #c2ccd9;
  --text: #1e2430;
  --muted: #6b7686;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #e8f0fe;
  --danger: #d93a3a;
  --danger-soft: #fdecec;
  --ok: #0f9d58;
  --radius: 8px;
  --row-h: 21px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 10px;
  border-right: 1px solid var(--line);
  flex: 0 0 auto;
}

.logo {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: grid;
  place-items: center;
  letter-spacing: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  flex: 0 0 auto;
  white-space: nowrap;
}

.brand-text strong {
  font-size: 13.5px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.ver {
  font-size: 11px;
  color: var(--muted);
}

.product {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.product-label {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.product-path {
  min-width: 0;
  max-width: 620px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  padding: 4px 8px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: var(--panel-alt);
  color: #33415c;
  font-family: Consolas, "Microsoft YaHei UI", monospace;
  font-size: 12px;
  cursor: pointer;
}

.product-path:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.top-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

/* ---------- 通用按钮 ---------- */
.btn {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s ease;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: #4a5568;
}

.btn.ghost:hover:not(:disabled) {
  background: #eef2f8;
  color: var(--accent);
  border-color: transparent;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #fff;
}

.btn.danger {
  background: #fff;
  border-color: #e2b6b6;
  color: var(--danger);
}

.btn.danger:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.btn.wide {
  min-width: 132px;
}

.btn.small {
  height: 24px;
  padding: 0 8px;
  font-size: 12px;
}

.icon-btn {
  width: 28px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
}

/* ---------- 四栏 ---------- */
.boxes {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 2.5fr;
  gap: 8px;
  padding: 8px;
}

.box {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(20, 32, 52, 0.04);
  overflow: hidden;
}

.box-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 10px 5px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(#fbfcfe, #f4f7fb);
}

.box-title {
  font-weight: 700;
  font-size: 13px;
  color: #1b3a63;
}

.box-title b {
  color: var(--accent);
}

.box-count {
  font-size: 11.5px;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
}

.box-tools {
  display: flex;
  gap: 5px;
  padding: 7px 8px 0;
  flex-wrap: wrap;
}

.box-tools .btn {
  flex: 0 1 auto;
}

.box-select {
  padding: 6px 8px 0;
}

.preset-select {
  width: 100%;
  height: 26px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  padding: 0 6px;
  cursor: pointer;
}

.list-wrap {
  flex: 1 1 auto;
  min-height: 0;
  padding: 6px 8px 0;
  display: flex;
}

.editbox {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  border: 1px solid #cbd6e4;
  border-radius: 6px;
  padding: 5px 8px;
  background: #fff;
  color: #26303f;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", Consolas, monospace;
  font-size: 12.5px;
  line-height: 21px;
  resize: none;
  outline: none;
  white-space: pre;
  overflow: auto;
  tab-size: 4;
  user-select: text;
}

.editbox::placeholder {
  color: #9aa4b2;
}

.editbox:hover {
  border-color: #b9c8dc;
}

.editbox:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.10);
}

.editbox::selection {
  background: #cfe0fd;
}

.box-actions {
  display: flex;
  gap: 5px;
  padding: 6px 8px 8px;
  flex-wrap: wrap;
}

.box-actions .btn {
  flex: 1 1 0;
  min-width: 52px;
}

.box.is-4 .box-actions .btn {
  flex: 0 1 auto;
}

/* ---------- 底栏 ---------- */
.bottombar {
  flex: 0 0 auto;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 7px 10px 4px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
}

.sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  margin: 0 3px;
}

.grow {
  flex: 1;
}

.field-label {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  padding-left: 4px;
}

.format-input {
  width: 300px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  font-family: "Microsoft YaHei UI", Consolas, monospace;
}

.format-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.status-row {
  min-height: 24px;
  gap: 10px;
  padding: 2px 2px 4px;
}

.status-text {
  font-size: 12px;
  color: #47536b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-text.ok {
  color: var(--ok);
}

.status-text.err {
  color: var(--danger);
}

.status-extra {
  font-size: 11.5px;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
}

.progress {
  flex: 1;
  height: 6px;
  max-width: 420px;
  background: #e6ebf3;
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
  transition: width 0.15s linear;
}

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.34);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  animation: fade 0.12s ease;
}

@keyframes fade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal {
  background: var(--panel);
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.28);
  display: flex;
  flex-direction: column;
  max-height: 88vh;
  max-width: 94vw;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 13.5px;
  background: linear-gradient(#fbfcfe, #f5f8fc);
}

.modal-head .close {
  margin-left: auto;
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.modal-head .close:hover {
  background: #eef2f8;
  color: var(--danger);
}

.modal-body {
  padding: 12px 14px;
  overflow: auto;
  min-height: 0;
}

.modal-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--panel-alt);
}

.modal-foot .left {
  margin-right: auto;
}

/* ---------- 表单 ---------- */
.group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px 12px;
  margin-bottom: 10px;
  background: #fff;
}

.group>legend,
.group-title {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  padding: 0 4px;
}

.region-grid {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.region-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.region-name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 92px;
  color: #33415c;
  font-size: 12.5px;
}

.chk {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px 2px 2px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12.5px;
  white-space: nowrap;
}

.chk:hover {
  background: var(--accent-soft);
}

.chk input {
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.region-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-left: auto;
}

.cond-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 6px 12px;
  align-items: start;
}

.cond-grid .radio {
  white-space: normal;
  align-items: flex-start;
}

.cond-grid .radio input {
  margin-top: 3px;
}

.radio {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 2px 0;
  font-size: 12.5px;
  white-space: nowrap;
}

.radio input {
  margin: 0;
  accent-color: var(--accent);
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.form-row>label {
  width: 86px;
  color: #47536b;
  font-size: 12.5px;
  text-align: right;
  flex: 0 0 auto;
}

.input,
.textarea {
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  flex: 1;
  min-width: 120px;
}

.input:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.textarea {
  height: auto;
  padding: 6px 8px;
  resize: vertical;
  min-height: 64px;
  font-family: "Microsoft YaHei UI", Consolas, monospace;
  line-height: 1.5;
}

/* ---------- 预览/文件列表 ---------- */
.preview-box {
  border: 1px solid var(--line);
  border-radius: 6px;
  height: 300px;
  overflow: auto;
  background: #fff;
  padding: 6px 8px;
  font-family: "Microsoft YaHei UI", Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.9;
  user-select: text;
}

.preview-box div {
  white-space: pre-wrap;
  word-break: break-all;
}

.file-list {
  border: 1px solid var(--line);
  border-radius: 6px;
  height: 220px;
  overflow: auto;
  background: #fff;
}

.file-item {
  padding: 6px 10px;
  border-bottom: 1px solid #f0f3f8;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: center;
}

.file-item:hover {
  background: var(--accent-soft);
}

.file-item.sel {
  background: #d7e5fd;
}

.file-item .name {
  font-weight: 600;
  color: #26303f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item .meta {
  margin-left: auto;
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}

/* ---------- 右键菜单 ---------- */
.ctx-menu {
  position: fixed;
  z-index: 120;
  min-width: 150px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
  padding: 4px;
  font-size: 12.5px;
}

.ctx-menu div {
  padding: 6px 10px;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  gap: 8px;
}

.ctx-menu div:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.ctx-menu div.disabled {
  color: #aab3c0;
  cursor: default;
  background: transparent;
}

.ctx-menu hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 4px 2px;
}

/* 滚动条 */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #c9d2de;
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: #a9b6c7;
  background-clip: content-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* 两列表单布局 */
.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.two-col .form-row > label {
  width: 64px;
  font-size: 12px;
}

.two-col .group {
  padding: 8px 10px 10px;
}

.two-col .input {
  min-width: 60px;
}
