:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #e3e7ee;
  --line-strong: #cfd6e0;
  --text: #1b1f24;
  --muted: #6b7280;
  --brand: #1f5fa8;
  --brand-dark: #174a83;
  --brand-soft: #eaf1fb;
  --ok: #15803d;
  --ok-soft: #e8f5ec;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: 14px; color: inherit; }
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 20%, #e8eef8 0%, transparent 45%),
    radial-gradient(circle at 85% 80%, #eaf3ee 0%, transparent 45%),
    var(--bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(16, 24, 40, .08);
  padding: 32px 30px 28px;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: .5px;
}

.login-card .sub {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 24px;
}

.login-card .hint {
  margin-top: 16px;
  padding: 10px 12px;
  background: var(--brand-soft);
  border-radius: 8px;
  color: #35507a;
  font-size: 12px;
  line-height: 1.7;
}

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px;
  flex: 0 0 216px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--line);
}

.brand .name { font-size: 15px; font-weight: 500; }
.brand .tag { font-size: 11px; color: var(--muted); letter-spacing: .8px; }

.nav { padding: 10px 10px; flex: 1; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #374151;
  cursor: pointer;
  font-size: 13.5px;
  margin-bottom: 2px;
  user-select: none;
}

.nav-item:hover { background: #f2f5f9; }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.nav-item .ico { width: 16px; text-align: center; opacity: .8; font-size: 13px; }

.nav-sep {
  margin: 10px 12px 6px;
  font-size: 11px;
  color: #9ca3af;
  letter-spacing: 1px;
}

.sidebar-foot { padding: 12px 16px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 56px;
  flex: 0 0 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h2 { margin: 0; font-size: 15px; font-weight: 500; }
.topbar .who { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }

main#view { padding: 20px 22px 40px; flex: 1; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-head h3 { margin: 0; font-size: 14px; font-weight: 500; }
.card-head .desc { font-size: 12px; color: var(--muted); }
.card-body { padding: 16px 18px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}

.btn:hover { background: #f7f9fc; border-color: #b9c3d1; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f2f5f9; color: var(--text); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 6px; }
.btn-danger { color: var(--danger); border-color: #f3c9c9; }
.btn-danger:hover { background: var(--danger-soft); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12px; color: var(--muted); }
.field > label .req { color: var(--danger); margin-left: 2px; }

input[type=text], input[type=number], input[type=password], select, textarea {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  outline: none;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}

textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 60px; }

input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 95, 168, .1);
}

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.hr { height: 1px; background: var(--line); margin: 16px 0; border: 0; }

.sub-title {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .5px;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sub-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* 参照原系统的行式表单：左侧标签 + 右侧内容 */
.frow {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed #f0f2f6;
}
.frow:last-child { border-bottom: 0; }
.frow > .flabel {
  flex: 0 0 96px;
  background: #f4f6fa;
  color: #47526b;
  font-size: 13px;
  text-align: center;
  line-height: 34px;
  height: 34px;
  border-radius: 6px;
  white-space: nowrap;
}
.frow > .fbody { flex: 1; min-width: 0; }
.frow .radio-line,
.frow .chk-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: center;
  min-height: 34px;
}
.frow .chk-line label.chk,
.frow .radio-line label.chk { margin: 0; }
/* 表面处理「单面/双面」内联单选组（替代原下拉菜单） */
.frow .side-r { display: inline-flex; gap: 10px; align-items: center; margin-left: 2px; }
.frow .side-r label.chk { margin: 0; white-space: nowrap; }
.frow .dim-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* 字段名与输入框同行紧挨（腰封展开尺寸）：标签按内容收窄，输入框紧随其后 */
.frow.frow-in { gap: 8px; align-items: center; }
.frow.frow-in > .flabel { flex: 0 0 auto; padding: 0 10px; }
.frow.frow-in > .fbody { flex: 0 1 auto; max-width: calc(100% - 120px); }
.frow .dim-line input { width: 110px; }
.frow .dim-x { color: var(--muted); font-size: 14px; }
.frow .hint-i { color: var(--muted); font-size: 12px; margin-left: 4px; }

/* 不干胶成品尺寸快捷档芯片（参照原系统：选中深色） */
.size-preset,
.chip {
  min-width: 88px;
  padding: 7px 12px;
  font-size: 13px;
  text-align: center;
  background: #f4f6fa;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  color: #47526b;
  line-height: 1.2;
}
.size-preset:hover,
.chip:hover { border-color: #b9c3d6; }
.size-preset.active,
.chip.active {
  background: #333f57;
  border-color: #333f57;
  color: #fff;
  font-weight: 600;
}

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  background: #fafbfd;
  white-space: nowrap;
  vertical-align: middle;
}
table.tbl td { padding: 9px 10px; border-bottom: 1px solid #f0f2f6; vertical-align: middle; }
/* 字段之间竖线分隔（后台参数表格）；表头与内容垂直居中对齐 */
.adm-main .tbl th + th, .adm-main .tbl td + td { border-left: 1px solid #e7ebf2; }
.adm-main .tbl th.num, .adm-main .tbl td.num { text-align: right; }
.adm-main .tbl th, .adm-main .tbl td { vertical-align: middle !important; }
.adm-main .tbl td .inline-wrap,
.adm-main .tbl td .tag,
.adm-main .tbl td .btn,
.adm-main .tbl td input,
.adm-main .tbl td select { vertical-align: middle; }
/* 行内编辑：点 ✎ 直接改数值（✎ 与数值同行垂直居中） */
.btn-xs { padding: 1px 6px; font-size: 11px; line-height: 1.4; }
.inline-wrap { display: inline-flex; align-items: center; gap: 5px; vertical-align: middle; line-height: 1.4; }
.inline-wrap .btn-xs { display: inline-flex; align-items: center; justify-content: center; height: 20px; }
.inline-input {
  width: 96px; padding: 2px 6px; font-size: 12.5px; line-height: 1.4;
  border: 1px solid var(--brand); border-radius: 4px; outline: none;
}
table.tbl tbody tr:hover { background: #fafcfe; }
table.tbl tbody tr.sel { background: var(--brand-soft); }
/* 防挤压：列表格列宽按内容走，超宽时横向滚动，不再把文字挤成竖排 */
.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl-fix th, .tbl-fix td { white-space: nowrap; }
.tbl-fix td.wrap, .tbl-fix th.wrap { white-space: normal; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 500; }
.nowrap { white-space: nowrap; }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  line-height: 18px;
  background: #f0f2f6;
  color: #4b5563;
}
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-danger { background: var(--danger-soft); color: var(--danger); }
.tag-brand { background: var(--brand-soft); color: var(--brand); }

/* ---------- 产品选择 ---------- */
.prod-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }

.prod {
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 12px 10px;
  text-align: center;
  cursor: pointer;
  background: #fff;
  transition: all .15s;
}

.prod:hover { border-color: #a9b9cd; }
.prod.active { border-color: var(--brand); background: var(--brand-soft); }
.prod .pn { font-weight: 500; font-size: 13.5px; }
.prod .pd { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- 工序勾选 ---------- */
.chk-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 14px; }

.chk {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  cursor: pointer;
  padding: 5px 0;
}

.chk input { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }
.chk .p { color: var(--muted); font-size: 11.5px; }

/* ---------- 结果 ---------- */
.result-head {
  display: flex;
  align-items: baseline;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: linear-gradient(180deg, #f8fbff, #fff);
  border-bottom: 1px solid var(--line);
}

.big-price { font-size: 26px; font-weight: 500; color: var(--brand); font-variant-numeric: tabular-nums; }
.big-price .u { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 4px; }

.kv { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.kv b { color: var(--text); font-weight: 500; }

.bd-group { border: 1px solid var(--line); border-radius: 9px; margin-bottom: 10px; overflow: hidden; }
.bd-group > .h {
  display: flex;
  justify-content: space-between;
  padding: 9px 12px;
  background: #fafbfd;
  font-size: 12.5px;
  font-weight: 500;
  border-bottom: 1px solid var(--line);
}
.bd-group > .h .amt { font-variant-numeric: tabular-nums; color: var(--brand); }
.bd-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 12px; font-size: 12.5px; border-bottom: 1px solid #f4f6f9; }
.bd-row:last-child { border-bottom: 0; }
.bd-row .d { color: var(--muted); font-size: 11.5px; }
.bd-row .amt { font-variant-numeric: tabular-nums; white-space: nowrap; }

.empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, .35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}

.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(16, 24, 40, .2);
}

.modal-head { padding: 15px 18px; border-bottom: 1px solid var(--line); font-weight: 500; font-size: 14px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #1f2937;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all .22s;
  z-index: 90;
  max-width: 80vw;
}

#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: #991b1b; }
#toast.ok { background: #166534; }

/* ---------- 后台 tab ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 9px 14px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 500; }

/* ---------- 参数后台：左侧纵向导航 + 搜索 ---------- */
.adm-wrap { display: flex; gap: 18px; align-items: flex-start; }
.adm-nav {
  width: 176px; flex: none; position: sticky; top: 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.adm-nav input {
  height: 34px; border: 1px solid var(--line); border-radius: 8px;
  padding: 0 10px; font-size: 13px; background: #fff; width: 100%;
}
.adm-nav input:focus { outline: none; border-color: var(--brand); }
.adm-nav-list { display: flex; flex-direction: column; gap: 2px; }
.adm-nav-item {
  padding: 9px 12px; border-radius: 8px; font-size: 13px;
  color: var(--muted); cursor: pointer; user-select: none;
}
.adm-nav-item:hover { background: #f2f5fa; color: var(--text); }
.adm-nav-item.active { background: #eaf2fd; color: var(--brand); font-weight: 600; }
.adm-nav-item.grp { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }
.adm-nav-item.grp .tri { font-size: 30px; line-height: 0.72; color: var(--muted); width: 26px; flex: none; }
.adm-nav-item .tri { font-size: 28px; line-height: 0.72; }
.adm-sub { display: flex; flex-direction: column; gap: 1px; }
.adm-sub .adm-nav-item { padding: 6px 12px 6px 28px; font-size: 12.5px; }
.adm-sub .adm-nav-item.grp2 { font-weight: 500; color: var(--text); }
.adm-sub2 { display: flex; flex-direction: column; gap: 1px; }
.adm-sub2 .adm-nav-item { padding: 5px 12px 5px 44px; font-size: 12px; }
.adm-sub3 { display: flex; flex-direction: column; gap: 1px; }
.adm-sub3 .adm-nav-item { padding: 5px 12px 5px 60px; font-size: 11.5px; }
.adm-mats { display: flex; flex-direction: column; }
.adm-mat {
  padding: 3px 12px 3px 74px; font-size: 11.5px; color: var(--muted);
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.adm-mat:hover { color: var(--brand); background: #f6f9fe; }
.adm-main { flex: 1; min-width: 0; }
.adm-home { padding: 90px 32px 60px; text-align: center; }
.adm-home-hello { font-size: 19px; font-weight: 600; color: var(--text); letter-spacing: .3px; line-height: 1.6; }
.adm-home-tip { margin-top: 12px; font-size: 13px; color: var(--muted); }
@media (max-width: 760px) { .adm-home { padding: 48px 16px 32px; text-align: left; } }
.lad-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.lad-row input { height: 32px; }
.lad-head { font-weight: 600; font-size: 13px; margin: 4px 0 8px; }
@media (max-width: 900px) {
  .adm-wrap { flex-direction: column; }
  .adm-nav { position: static; width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .adm-nav-list { flex-direction: row; flex-wrap: wrap; }
}

/* ---------- 打印 ---------- */
.print-sheet { display: none; }

@media print {
  @page { size: A4; margin: 14mm 14mm; }
  body { background: #fff; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
  .sidebar, .topbar, #toast, .no-print { display: none !important; }
  main#view { padding: 0 !important; }
  .card { border: 0; box-shadow: none; margin: 0; }
  .print-sheet { display: block !important; }
  .screen-only { display: none !important; }
}

@media (max-width: 1080px) {
  .result-split { grid-template-columns: minmax(0, 1fr) !important; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .prod-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chk-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 12px 16px; }
  .nav { display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px; }
  .nav-item { white-space: nowrap; margin: 0; }
  .nav-sep, .sidebar-foot { display: none; }
  main#view { padding: 14px; }
  .g3, .g4, .g6, .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .prod-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { padding: 0 14px; height: auto; min-height: 52px; }
  .topbar h2 { font-size: 14px; }
}
