:root {
  --primary: #165DFF;
  --primary-600: #0E42D2;
  --primary-50: #EAF1FF;
  --sidebar: #0B1526;
  --sidebar-2: #101D31;
  --bg: #F5F7FA;
  --card: #ffffff;
  --text: #1D2129;
  --text-2: #4E5969;
  --text-3: #86909C;
  --line: #E5E6EB;
  --line-2: #F2F3F5;
  --green: #00B42A;
  --green-50: #E8FFEA;
  --orange: #FF7D00;
  --orange-50: #FFF7E8;
  --red: #F53F3F;
  --red-50: #FFECE8;
  --blue-50: #E8F0FF;
  --seal: #C8102E;
  --shadow-sm: 0 1px 2px rgba(15, 27, 45, .04), 0 1px 3px rgba(15, 27, 45, .06);
  --shadow-md: 0 6px 24px rgba(15, 27, 45, .08);
  --shadow-lg: 0 18px 48px rgba(15, 27, 45, .16);
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

a { color: var(--primary); text-decoration: none; }

/* ============ 登录 ============ */
.login-root {
  position: fixed;
  inset: 0;
  display: flex;
  background: #fff;
  z-index: 50;
}

.login-brand {
  position: relative;
  width: 52%;
  padding: 56px 64px;
  color: #fff;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(22, 93, 255, .45), transparent 60%),
    radial-gradient(700px 500px at 90% 85%, rgba(0, 180, 255, .22), transparent 60%),
    linear-gradient(150deg, #0B1526 0%, #0E2038 55%, #0B2A4A 100%);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-brand::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(900px 600px at 30% 20%, #000 20%, transparent 80%);
  pointer-events: none;
}

.login-brand .brand-mark {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  z-index: 2;
}

.logo-badge {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(145deg, #2B7BFF, #165DFF);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 1px;
  box-shadow: 0 8px 20px rgba(22, 93, 255, .45);
}

.login-brand h1 {
  position: relative;
  z-index: 2;
  margin: 0 0 18px;
  font-size: 40px;
  line-height: 1.25;
  letter-spacing: 1px;
  font-weight: 600;
}

.login-brand h1 span { color: #6EA8FF; }

.login-brand p.lead {
  position: relative;
  z-index: 2;
  margin: 0;
  font-size: 15px;
  color: rgba(255, 255, 255, .68);
  line-height: 1.9;
  max-width: 460px;
}

.login-features {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 28px;
  margin-top: 40px;
  max-width: 520px;
}

.login-feature {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
  color: rgba(255, 255, 255, .76);
  line-height: 1.6;
}

.login-feature b {
  display: block;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}

.login-feature .dot {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  margin-top: 2px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .14);
  display: grid;
  place-items: center;
  color: #8DB8FF;
}

.login-foot {
  position: relative;
  z-index: 2;
  font-size: 12px;
  color: rgba(255, 255, 255, .35);
}

.login-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: #fff;
}

.login-box { width: 364px; }

.login-box h2 {
  margin: 0 0 8px;
  font-size: 26px;
  letter-spacing: .5px;
}

.login-box .sub {
  margin: 0 0 30px;
  color: var(--text-3);
  font-size: 13px;
}

.field { margin-bottom: 18px; }

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 7px;
}

.field label .req { color: var(--red); margin-left: 2px; }

.input, .select, .textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.6; }

.input:hover, .select:hover { border-color: #C9CDD4; }

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 93, 255, .10);
}

.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2386909C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.input::placeholder { color: #C9CDD4; }

#f-no { font-size: 13px; letter-spacing: 0; }

.input:disabled, .input[readonly] {
  background: #F7F8FA;
  color: var(--text-2);
  cursor: not-allowed;
}

.input.err, .select.err { border-color: var(--red); box-shadow: 0 0 0 3px rgba(245, 63, 63, .08); }

.err-msg { color: var(--red); font-size: 12px; margin-top: 6px; display: none; }
.field.has-err .err-msg { display: block; }
.hint { color: var(--text-3); font-size: 12px; margin-top: 6px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s ease;
  user-select: none;
}

.btn:hover { border-color: #C9CDD4; background: #FAFBFC; }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(22, 93, 255, .22);
}

.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }

.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-danger { color: var(--red); border-color: #FFD2CC; background: #fff; }
.btn-danger:hover { background: var(--red-50); }

.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 6px; }
.btn-lg { height: 44px; padding: 0 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-link { border: none; background: none; color: var(--primary); padding: 0 4px; height: auto; font-size: 13px; }
.btn-link:hover { color: var(--primary-600); background: none; }

.demo-box {
  margin-top: 28px;
  border-top: 1px dashed var(--line);
  padding-top: 18px;
}

.demo-box .t { font-size: 12px; color: var(--text-3); margin-bottom: 10px; }

.demo-chips { display: flex; gap: 8px; }

.demo-chip {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  background: #fff;
  text-align: left;
  transition: all .15s;
}

.demo-chip:hover { border-color: var(--primary); background: var(--primary-50); }
.demo-chip b { display: block; font-size: 13px; font-weight: 500; }
.demo-chip span { display: block; font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ============ 主框架 ============ */
.app-root { min-height: 100vh; }

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 236px;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 30;
  transition: width .2s ease;
}

.sidebar .brand {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.sidebar .brand .logo-badge { width: 34px; height: 34px; font-size: 16px; border-radius: 9px; }

.sidebar .brand .txt b { display: block; font-size: 15px; font-weight: 600; letter-spacing: .3px; }
.sidebar .brand .txt span { display: block; font-size: 10px; color: rgba(255, 255, 255, .42); letter-spacing: .5px; margin-top: 1px; }

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 20px;
}

.nav::-webkit-scrollbar { width: 0; }

.nav-group { margin-top: 16px; }
.nav-group:first-child { margin-top: 0; }

.nav-group .gt {
  font-size: 11px;
  color: rgba(255, 255, 255, .34);
  padding: 0 12px 8px;
  letter-spacing: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  color: rgba(255, 255, 255, .66);
  cursor: pointer;
  font-size: 13.5px;
  margin-bottom: 2px;
  transition: all .15s;
  position: relative;
}

.nav-item:hover { color: #fff; background: rgba(255, 255, 255, .06); }

.nav-item.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(22, 93, 255, .95), rgba(22, 93, 255, .72));
  box-shadow: 0 6px 16px rgba(22, 93, 255, .28);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 2px;
  background: #6EA8FF;
}

.nav-item svg { flex: none; opacity: .9; }

.nav-item .badge {
  margin-left: auto;
  font-size: 10px;
  background: var(--orange);
  color: #fff;
  border-radius: 9px;
  padding: 1px 6px;
  line-height: 15px;
}

.sidebar-foot {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, .06);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.sidebar-foot:hover { background: rgba(255, 255, 255, .04); }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(145deg, #3C7BFF, #165DFF);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex: none;
}

.sidebar-foot .who { min-width: 0; }
.sidebar-foot .who b { display: block; font-size: 13px; color: #fff; font-weight: 500; }
.sidebar-foot .who span { display: block; font-size: 11px; color: rgba(255, 255, 255, .4); margin-top: 1px; }
.sidebar-foot .out { margin-left: auto; color: rgba(255, 255, 255, .4); display: flex; }
.sidebar-foot .out:hover { color: #fff; }

.main { margin-left: 236px; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: 64px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.crumb { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 13px; }
.crumb b { color: var(--text); font-weight: 500; }
.crumb .sep { color: #C9CDD4; }

.topbar .spacer { flex: 1; }

.top-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--text-2);
  cursor: pointer;
  border: none;
  background: transparent;
}

.icon-btn:hover { background: var(--bg); color: var(--text); }

.top-user { display: flex; align-items: center; gap: 9px; padding-left: 10px; border-left: 1px solid var(--line); }
.top-user .name { font-size: 13px; line-height: 1.2; }
.top-user .name span { display: block; font-size: 11px; color: var(--text-3); margin-top: 2px; }

.view { padding: 24px; flex: 1; width: 100%; max-width: 1500px; margin: 0 auto; }

/* ============ 页面通用 ============ */
.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.page-head h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: .2px; }
.page-head .sub { margin: 7px 0 0; color: var(--text-3); font-size: 13px; }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }

.card {
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-hd {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-2);
}

.card-hd h3 { margin: 0; font-size: 15px; font-weight: 600; }
.card-hd .sub { font-size: 12px; color: var(--text-3); }
.card-hd .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.card-bd { padding: 20px; }
.card-bd.tight { padding: 12px 20px; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.stat {
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.stat .label { color: var(--text-3); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.stat .num { font-size: 28px; font-weight: 600; margin-top: 10px; letter-spacing: .4px; font-variant-numeric: tabular-nums; }
.stat .num small { font-size: 14px; font-weight: 400; color: var(--text-3); margin-left: 4px; }
.stat .foot { margin-top: 10px; font-size: 12px; color: var(--text-3); display: flex; gap: 6px; align-items: center; }
.stat .foot .up { color: var(--green); }
.stat .ico {
  position: absolute;
  right: 16px;
  top: 16px;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: grid;
  place-items: center;
}
.stat .ico.blue { background: var(--blue-50); color: var(--primary); }
.stat .ico.green { background: var(--green-50); color: var(--green); }
.stat .ico.orange { background: var(--orange-50); color: var(--orange); }
.stat .ico.gray { background: #F2F3F5; color: var(--text-2); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border-radius: 5px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.draft { background: #F2F3F5; color: #4E5969; }
.tag.confirmed { background: var(--blue-50); color: var(--primary); }
.tag.sealed { background: var(--green-50); color: #009A29; }
.tag.voided { background: var(--red-50); color: #CB2634; }
.tag.plain::before { display: none; }

.table-wrap { width: 100%; overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.table th {
  text-align: left;
  font-weight: 500;
  color: var(--text-3);
  background: #FAFBFC;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line-2);
  color: var(--text-2);
  vertical-align: middle;
}

.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #FAFBFF; }
.table tbody tr:last-child td { border-bottom: none; }

.table .no { font-family: "SFMono-Regular", Consolas, monospace; color: var(--text); font-size: 13px; font-weight: 500; white-space: nowrap; }
.table .strong { color: var(--text); font-weight: 500; }
.table .money { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 500; white-space: nowrap; }
.table .muted { color: var(--text-3); }
.table td.muted { white-space: nowrap; }

.table .row-actions { display: flex; gap: 2px; opacity: .7; transition: opacity .15s; }
.table tbody tr:hover .row-actions { opacity: 1; }
.table .qty { white-space: nowrap; }
.table .pname { color: var(--text-2); white-space: nowrap; }
.table .pspec { color: var(--text-3); font-size: 12px; }

.empty {
  padding: 64px 20px;
  text-align: center;
  color: var(--text-3);
}

.empty .big { font-size: 40px; opacity: .35; margin-bottom: 10px; }
.empty b { display: block; color: var(--text-2); font-weight: 500; margin-bottom: 6px; }

/* 筛选条 */
.filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-2);
}

.seg {
  display: inline-flex;
  background: #F2F3F5;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.seg button {
  border: none;
  background: transparent;
  color: var(--text-2);
  height: 30px;
  padding: 0 9px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  transition: all .15s;
}

.seg button:hover { color: var(--text); }
.seg button.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); font-weight: 500; }
.seg button .n { font-size: 11px; color: var(--text-3); margin-left: 3px; }

.search {
  position: relative;
  display: flex;
  align-items: center;
}

.search svg { position: absolute; left: 11px; color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 34px; width: 190px; height: 36px; }

.filters .select { width: 112px; height: 36px; }
.filters .spacer { flex: 1; }

.summary-bar {
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 12px 20px;
  background: #FAFBFC;
  border-top: 1px solid var(--line-2);
  font-size: 12.5px;
  color: var(--text-3);
  flex-wrap: wrap;
}

.summary-bar b { color: var(--text); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; margin-left: 4px; }
.summary-bar .push { margin-left: auto; }

.pager { display: flex; align-items: center; gap: 6px; }
.pager button {
  min-width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text-2);
  cursor: pointer;
  font-size: 12.5px;
}
.pager button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager button:disabled { opacity: .4; cursor: default; }

/* ============ 新建报价 ============ */
.editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 560px;
  gap: 20px;
  align-items: start;
}

.form-stack { display: grid; gap: 16px; }

.form-section { padding: 20px; }

.form-section .sec-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 18px;
}

.form-section .sec-title .idx {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--primary-50);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 12px;
}

.form-section .sec-title .tip { font-size: 12px; color: var(--text-3); font-weight: 400; margin-left: auto; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.row-3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 0 14px; }

.inline-btn { position: absolute; right: 6px; top: 6px; }

.input-wrap { position: relative; }

.calc-box {
  display: flex;
  align-items: baseline;
  gap: 14px;
  background: linear-gradient(180deg, #F8FAFF, #F4F7FE);
  border: 1px solid #E3EBFB;
  border-radius: 8px;
  padding: 13px 15px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.calc-box .k { font-size: 12px; color: var(--text-3); }
.calc-box .v { font-size: 19px; font-weight: 600; color: var(--primary); font-variant-numeric: tabular-nums; }
.calc-box .upper { font-size: 12.5px; color: var(--text-2); }
.calc-box .upper b { color: var(--text); font-weight: 500; }
.calc-box .spacer { flex: 1; }

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 16px 20px;
  background: #fff;
  border-top: 1px solid var(--line-2);
  border-radius: 0 0 var(--radius) var(--radius);
  flex-wrap: wrap;
}

.form-actions .hint-mini { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.form-actions .push { flex: 1; min-width: 12px; }

/* 预览 */
.preview-panel { position: sticky; top: 84px; }

.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--line-2);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 12.5px;
  color: var(--text-2);
}

.preview-toolbar .dot-live { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(0, 180, 42, .12); }
.preview-toolbar .spacer { flex: 1; }
.preview-toolbar .zoom { display: flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 6px; height: 26px; }
.preview-toolbar .zoom button { width: 24px; height: 24px; border: none; background: none; cursor: pointer; color: var(--text-2); font-size: 14px; }
.preview-toolbar .zoom span { min-width: 38px; text-align: center; font-size: 12px; color: var(--text-2); }

.preview-shell {
  background: #E9EDF3;
  border: 1px solid var(--line-2);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 22px;
  max-height: calc(100vh - 150px);
  overflow: auto;
}

.paper-wrap { display: flex; justify-content: center; }

/* ============ A4 合同纸 ============ */
.paper {
  width: 794px;
  min-height: 1123px;
  background: #fff;
  box-shadow: 0 10px 34px rgba(15, 27, 45, .14);
  padding: 92px 72px 58px;
  font-family: "SimSun", "宋体", "Songti SC", serif;
  font-size: 13.5px;
  line-height: 1.5;
  color: #111;
  zoom: var(--paper-zoom, .7);
  position: relative;
  flex: none;
}

.paper h1 {
  margin: 0 0 12px;
  text-align: center;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 9px;
  text-indent: 9px;
}

.paper .meta { width: 100%; border-collapse: collapse; margin-bottom: 2px; font-size: 13.5px; }
.paper .meta td { padding: 3px 0; vertical-align: bottom; }
.paper .meta .lbl { font-weight: 700; white-space: nowrap; width: 86px; }
.paper .meta .name { font-weight: 700; }
.paper .meta .right { text-align: right; white-space: nowrap; }
.paper .meta .no { color: #111; }

.paper .intro { margin: 4px 0 2px; text-indent: 0; }

.paper .clause { margin: 2px 0; text-align: justify; }

.paper table.items {
  width: 100%;
  border-collapse: collapse;
  margin: 2px 0 4px;
  font-size: 13px;
  table-layout: fixed;
}

.paper table.items th,
.paper table.items td {
  border: 1px solid #111;
  padding: 5px 4px;
  text-align: center;
  height: 30px;
  word-break: break-all;
}

.paper table.items th { font-weight: 400; font-size: 12px; white-space: nowrap; }

.paper table.items.compact td { height: 24px; padding: 3px 4px; font-size: 12px; }
.paper table.items.compact th { font-size: 11.5px; }

.paper table.items td.remark { font-size: 12.5px; line-height: 1.5; }
.paper table.items td.num { text-align: right; padding-right: 9px; }
.paper table.items td.upper { letter-spacing: .5px; }

.paper .sign {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 30px;
  font-size: 13.5px;
}

.paper .sign .col { position: relative; min-height: 96px; }
.paper .sign .line { margin-bottom: 22px; }
.paper .sign .rep { margin-top: 10px; }
.paper .seal-box { position: relative; height: 0; }

.paper .seal {
  position: absolute;
  left: 108px;
  top: -22px;
  width: 150px;
  height: 150px;
  transform: rotate(-7deg);
  opacity: .9;
  pointer-events: none;
  mix-blend-mode: multiply;
}

.paper .verify-strip {
  margin-top: 18px;
  padding-top: 8px;
  border-top: 1px dashed #bbb;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "Microsoft YaHei", sans-serif;
  font-size: 9.5px;
  color: #666;
}

.paper .verify-strip .qr {
  width: 46px;
  height: 46px;
  flex: none;
  display: block;
}

.paper .verify-strip b { color: #333; font-weight: 600; letter-spacing: .5px; }

.paper .paper-mark {
  position: absolute;
  top: 30px;
  right: 34px;
  font-family: "Microsoft YaHei", sans-serif;
  font-size: 10px;
  color: #B8BEC9;
  letter-spacing: 2px;
  border: 1px solid #DCE1E8;
  border-radius: 3px;
  padding: 2px 6px;
  transform: rotate(3deg);
}

/* ============ 详情 ============ */
.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.detail-head h2 { margin: 0; font-size: 22px; font-weight: 600; font-family: "SFMono-Regular", Consolas, monospace; letter-spacing: -.3px; }
.detail-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.info-list { display: grid; gap: 0; }
.info-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line-2); font-size: 13px; }
.info-row:last-child { border-bottom: none; }
.info-row .k { width: 88px; flex: none; color: var(--text-3); }
.info-row .v { color: var(--text); min-width: 0; word-break: break-all; }
.info-row .v.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }

.timeline { padding-left: 4px; }
.tl-item { position: relative; padding: 0 0 20px 24px; border-left: 1px solid var(--line); margin-left: 6px; }
.tl-item:last-child { border-left-color: transparent; padding-bottom: 0; }
.tl-item::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #C9CDD4;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #E5E6EB;
}
.tl-item.done::before { background: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.tl-item.sealed::before { background: var(--green); box-shadow: 0 0 0 1px var(--green); }
.tl-item .t { font-size: 13px; color: var(--text); font-weight: 500; }
.tl-item .d { font-size: 12px; color: var(--text-3); margin-top: 4px; line-height: 1.6; }

.seal-card {
  background: linear-gradient(135deg, #FFF8F6, #FFFDFC);
  border: 1px solid #F7DCD6;
  border-radius: 10px;
  padding: 16px;
}

.seal-card .t { font-size: 13px; color: #9B2C22; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.seal-card .code { font-family: "SFMono-Regular", Consolas, monospace; font-size: 20px; letter-spacing: 2px; color: #7A1E16; margin: 10px 0 8px; }
.seal-card .meta { font-size: 11.5px; color: #A8675F; line-height: 1.8; }
.seal-card .meta span { display: block; word-break: break-all; }

/* ============ 弹窗 ============ */
.modal-root { position: fixed; inset: 0; z-index: 100; display: none; }
.modal-root.open { display: block; }

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 27, 45, .45);
  backdrop-filter: blur(2px);
  animation: fadeIn .18s ease;
}

.modal {
  position: relative;
  background: #fff;
  border-radius: 14px;
  width: 480px;
  max-width: calc(100vw - 32px);
  margin: 8vh auto 0;
  box-shadow: var(--shadow-lg);
  animation: slideUp .22s cubic-bezier(.2, .8, .3, 1);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}

.modal.wide { width: 720px; }
.modal.xwide { width: 920px; }

.modal-hd {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 22px 0;
}

.modal-hd .ico {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--primary-50);
  color: var(--primary);
}

.modal-hd .ico.warn { background: var(--orange-50); color: var(--orange); }
.modal-hd .ico.danger { background: var(--red-50); color: var(--red); }
.modal-hd .ico.seal { background: #FFF0ED; color: var(--seal); }

.modal-hd h3 { margin: 2px 0 0; font-size: 17px; font-weight: 600; }
.modal-hd .sub { margin: 5px 0 0; font-size: 12.5px; color: var(--text-3); line-height: 1.6; }
.modal-hd .x { margin-left: auto; color: var(--text-3); cursor: pointer; background: none; border: none; padding: 4px; }
.modal-hd .x:hover { color: var(--text); }

.modal-bd { padding: 18px 22px; overflow-y: auto; }
.modal-ft { padding: 0 22px 20px; display: flex; justify-content: flex-end; gap: 10px; }

.summary-box {
  background: #FAFBFC;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13px;
}
.summary-box .line { display: flex; padding: 5px 0; gap: 10px; }
.summary-box .line .k { width: 72px; color: var(--text-3); flex: none; }
.summary-box .line .v { color: var(--text); font-weight: 500; }
.summary-box .line .v.big { font-size: 17px; color: var(--primary); font-variant-numeric: tabular-nums; }

.check-row { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--text-2); margin-top: 14px; line-height: 1.5; }
.check-row input { margin-top: 2px; }

.seal-select {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 4px;
}

.seal-opt {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  transition: all .15s;
}

.seal-opt:hover { border-color: #A9C3FF; }
.seal-opt.active { border-color: var(--seal); background: #FFF9F8; box-shadow: 0 0 0 2px rgba(200, 16, 46, .06); }
.seal-opt svg, .seal-opt img { width: 44px; height: 44px; flex: none; object-fit: contain; }
.seal-opt b { display: block; font-size: 13px; font-weight: 500; }
.seal-opt span { display: block; font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ============ 设置 / 表格 ============ */
.settings-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.settings-nav { padding: 10px; position: sticky; top: 84px; }
.settings-nav button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: none;
  background: none;
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  font-size: 13.5px;
  text-align: left;
}
.settings-nav button:hover { background: var(--bg); }
.settings-nav button.active { background: var(--primary-50); color: var(--primary); font-weight: 500; }

.seal-preview {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: #fff;
  border: 1px dashed #E5C6C2;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.seal-preview img, .seal-preview svg { width: 100%; height: 100%; object-fit: contain; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }

/* ============ 其他 ============ */
.toast-root {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1D2129;
  color: #fff;
  border-radius: 9px;
  padding: 10px 15px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .2s ease;
  max-width: 560px;
}
.toast.success { background: #0E7A2E; }
.toast.error { background: #B3261E; }
.toast.warn { background: #9A5B00; }
.toast .i { display: flex; }

.loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: var(--primary);
  width: 0;
  z-index: 300;
  transition: width .3s ease;
}

.chart-card { padding: 18px 20px 8px; }
.chart { display: flex; align-items: flex-end; gap: 14px; height: 132px; padding: 8px 0 0; }
.chart .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart .bar .b { width: 100%; max-width: 36px; border-radius: 5px 5px 2px 2px; background: linear-gradient(180deg, #6EA8FF, #165DFF); min-height: 4px; transition: height .4s ease; opacity: .9; }
.chart .bar .b.muted { background: linear-gradient(180deg, #C9D8F5, #9DB9EA); }
.chart .bar .l { font-size: 11px; color: var(--text-3); }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-action {
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: all .15s;
  background: #fff;
  text-align: left;
}
.quick-action:hover { border-color: #B9CEFF; background: #FAFCFF; transform: translateY(-1px); }
.quick-action .qi { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); margin-bottom: 9px; }
.quick-action b { display: block; font-size: 13px; font-weight: 500; }
.quick-action span { display: block; font-size: 11px; color: var(--text-3); margin-top: 3px; }

.dash-main, .dash-bottom { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; margin-top: 16px; align-items: start; }

.todo-item { display: flex; align-items: center; gap: 10px; padding: 11px 4px; border-bottom: 1px dashed var(--line-2); cursor: pointer; }
.todo-item:last-child { border-bottom: none; }
.todo-item:hover .tt b { color: var(--primary); }
.tico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.tico.draft { background: #F2F3F5; color: var(--text-2); }
.tico.pending { background: #FFF7E8; color: #FF7D00; }
.tt { min-width: 0; flex: 1; }
.tt b { display: block; font-size: 12.5px; font-weight: 500; font-family: "SFMono-Regular", Consolas, monospace; }
.tt span { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tarr { color: #C9CDD4; display: flex; }

.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.meta-pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 5px; background: #F2F3F5; color: var(--text-2); font-size: 11.5px; }

.seller-tag { font-size: 10px; color: var(--text-3); margin-top: 3px; letter-spacing: .2px; }
.settle-tag { font-size: 10.5px; color: var(--text-3); font-weight: 400; margin-top: 3px; }
.multi-tag { font-size: 10.5px; color: var(--primary); background: var(--primary-50); padding: 1px 5px; border-radius: 4px; font-weight: 400; margin-left: 2px; }

.note { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 12px; line-height: 1.7; display: flex; align-items: flex-start; gap: 6px; }

/* 产品明细编辑 */
.items-scroll { width: 100%; overflow-x: auto; }
.items-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.items-table th { font-size: 11px; color: var(--text-3); font-weight: 500; text-align: left; padding: 0 4px 7px; line-height: 1.35; }
.items-table td { padding: 3px 3px; vertical-align: middle; }
.items-table .input { height: 36px; padding: 0 6px; font-size: 12.5px; }
.items-table input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
.items-table input[type="number"]::-webkit-outer-spin-button,
.items-table input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.items-table .item-amount { background: #F7F8FA; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.items-table .item-del { color: var(--text-3); width: 30px; height: 30px; }
.items-table .item-del:hover { color: var(--red); background: var(--red-50); }
.items-table tr.row-err td { background: #FFF8F7; }
.items-table .input.err { border-color: var(--red); box-shadow: 0 0 0 3px rgba(245, 63, 63, .08); }
.items-foot { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.items-foot .hint { margin: 0; }

.seg-radio { display: flex; gap: 8px; }
.radio-pill {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 20px;
  cursor: pointer; font-size: 13px; display: flex; gap: 6px; align-items: center;
  background: #fff; transition: .15s;
}
.radio-pill:hover { border-color: #B9CEFF; }
.radio-pill.active { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
.radio-pill input { accent-color: var(--primary); }

.section-title { font-size: 14px; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title .more { margin-left: auto; font-size: 12px; font-weight: 400; color: var(--primary); cursor: pointer; }

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

.permission-table td, .permission-table th { text-align: center; }
.permission-table td:first-child, .permission-table th:first-child { text-align: left; }
.permission-table .yes { color: var(--green); font-weight: 600; }
.permission-table .no { color: #C9CDD4; }

.role-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 8px; border-radius: 5px; background: #F2F3F5; color: var(--text-2); }
.role-badge.admin { background: #E8F0FF; color: #165DFF; }
.role-badge.sales { background: #E8FFEA; color: #0E7A2E; }
.role-badge.viewer { background: #F5F0FF; color: #7B4FD1; }

#print-area { display: none; }

@media (max-width: 1320px) {
  .editor { grid-template-columns: minmax(0, 1fr) 540px; }
}

@media (max-width: 1180px) {
  .editor { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
  .preview-shell { max-height: 720px; }
  .detail-layout { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .dash-main, .dash-bottom { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .sidebar { width: 72px; }
  .sidebar .brand .txt, .sidebar-foot .who, .sidebar-foot .out, .nav-group .gt, .nav-item span, .nav-item .badge { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .sidebar .brand { justify-content: center; padding: 0; }
  .main { margin-left: 72px; }
  .login-brand { display: none; }
  .login-panel { width: 100%; }
  .view { padding: 16px; }
  .topbar { padding: 0 16px; }
  .row-3 { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .grid-4, .grid-2, .grid-3, .row-2, .row-3 { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
  .page-head .actions { margin-left: 0; }
  .top-user .name { display: none; }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

@media print {
  @page { size: A4; margin: 0; }

  body { background: #fff !important; }

  #app-root, .login-root, .modal-root, .toast-root, .loading-bar { display: none !important; }

  #print-area { display: block !important; }

  #print-area .paper {
    width: 210mm;
    min-height: 297mm;
    padding: 25.4mm 19.05mm;
    box-shadow: none;
    zoom: 1;
    margin: 0;
  }

  .no-print { display: none !important; }
}
