:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #dbe4ee;
  --text: #162033;
  --muted: #66758a;
  --primary: #1769e0;
  --primary-dark: #0f4fb1;
  --green: #15956b;
  --amber: #b97613;
  --red: #c83737;
  --teal: #0b8793;
  --shadow: 0 16px 40px rgba(24, 39, 75, .12);
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.hidden { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 420px;
  align-items: center;
  gap: 56px;
  padding: 56px max(32px, 9vw);
  background:
    linear-gradient(115deg, rgba(23, 105, 224, .14), transparent 42%),
    linear-gradient(180deg, #f8fbff, #eef5fd);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 22px;
}

.brand-mark {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
  background: linear-gradient(135deg, #1769e0, #0b8793);
  box-shadow: 0 18px 36px rgba(23, 105, 224, .24);
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  font-size: 14px;
}

.login-brand h1 {
  margin: 0 0 12px;
  font-size: 38px;
  line-height: 1.15;
}

.login-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.panel-title strong { font-size: 22px; }
.panel-title span { color: var(--green); font-size: 13px; }

.login-remember {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin: -2px 0 18px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.login-remember input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.login-remember span { line-height: 16px; }

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 105, 224, .12);
}

.primary-btn, .ghost-btn, .danger-btn {
  height: 38px;
  border-radius: 6px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.primary-btn {
  width: 100%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.primary-btn:hover { background: var(--primary-dark); }
.ghost-btn { background: #eef4fb; color: var(--text); border: 1px solid var(--line); }
.danger-btn { background: #fff0f0; color: var(--red); border: 1px solid #ffd3d3; }
.form-error { min-height: 20px; margin: 12px 0 0; color: var(--red); font-size: 13px; }

.main-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(23,105,224,.18), transparent 30%),
    linear-gradient(180deg, #111b2e 0%, #0b1324 100%);
  color: #d8e4f2;
  min-height: 100vh;
  padding: 16px 12px;
  position: sticky;
  top: 0;
  border-right: 1px solid rgba(255,255,255,.08);
  box-shadow: 14px 0 32px rgba(15, 23, 42, .12);
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  background: rgba(255,255,255,.06);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}

.sidebar-brand strong { display: block; color: #fff; letter-spacing: 0; }
.sidebar-brand span { display: block; color: #9fb0c4; font-size: 12px; margin-top: 4px; }

.nav-menu {
  display: grid;
  gap: 3px;
  padding-bottom: 92px;
}

.nav-group {
  display: grid;
  gap: 4px;
}

.nav-section-title {
  padding: 16px 12px 6px;
  color: #73849a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
}

.nav-item {
  position: relative;
  height: 44px;
  width: 100%;
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  padding: 0 10px;
  color: #c9d6e6;
  background: transparent;
  text-align: left;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}

.nav-item::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 9px;
  width: 3px;
  height: 26px;
  border-radius: 0 3px 3px 0;
  background: transparent;
}

.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
  transform: translateX(2px);
}

.nav-item.active {
  color: #fff;
  background: linear-gradient(135deg, #1769e0, #0b8793);
  box-shadow: 0 12px 24px rgba(23, 105, 224, .24);
}

.nav-item.active::before {
  background: #65d6ff;
}

.nav-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  color: #d9e7f7;
  font-size: 14px;
  text-align: center;
}

.nav-item.active .nav-icon {
  background: rgba(255,255,255,.2);
  color: #fff;
}

.nav-badge {
  min-width: 34px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 8px;
  color: #91a4bb;
  background: rgba(255,255,255,.06);
  font-size: 11px;
  font-style: normal;
}

.nav-item.active .nav-badge {
  color: rgba(255,255,255,.86);
  background: rgba(255,255,255,.18);
}

.nav-children {
  display: none;
  gap: 2px;
  margin: 2px 0 4px 25px;
  padding: 2px 0 2px 18px;
  border-left: 1px solid rgba(255,255,255,.12);
}

.nav-group.open .nav-children {
  display: grid;
}

.nav-child {
  position: relative;
  height: 32px;
  border-radius: 7px;
  padding: 0 12px;
  color: #9fb0c4;
  background: transparent;
  text-align: left;
  font-size: 13px;
}

.nav-child::before {
  content: "";
  position: absolute;
  left: -22px;
  top: 15px;
  width: 12px;
  height: 1px;
  background: rgba(255,255,255,.14);
}

.nav-child:hover,
.nav-child.active {
  color: #fff;
  background: rgba(23,105,224,.22);
}

.sidebar-footer {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 14px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  color: #9fb0c4;
  background: rgba(255,255,255,.05);
}

.sidebar-footer span {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.sidebar-footer strong {
  color: #fff;
  font-size: 13px;
}

.content {
  min-width: 0;
  padding: 0 24px 32px;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 3;
  background: rgba(244, 247, 251, .94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(219, 228, 238, .8);
}

.topbar h2 { margin: 0 0 4px; font-size: 22px; }
.topbar p { margin: 0; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  font-size: 18px;
}

.user-chip {
  height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px 0 12px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
}

.user-chip span {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  font-weight: 700;
}
.user-chip span:hover { color: var(--primary); }
.user-chip button {
  height: 28px;
  padding: 0 10px;
  border-radius: 5px;
  color: var(--muted);
  background: var(--surface-soft);
}

.page-body {
  padding-top: 20px;
}

.section-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.section-tabs button {
  height: 32px;
  min-width: 88px;
  border-radius: 5px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
}

.section-tabs button.active {
  color: #fff;
  background: var(--primary);
  font-weight: 700;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid #cfe0f6;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(23, 105, 224, .10), rgba(11, 135, 147, .08)),
    #fff;
}

.dashboard-hero span {
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.dashboard-hero h3 {
  margin: 6px 0;
  font-size: 22px;
}

.dashboard-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.dashboard-hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
}

.dashboard-hero-metrics div {
  min-width: 120px;
  padding: 12px;
  border: 1px solid rgba(23, 105, 224, .16);
  border-radius: 8px;
  background: rgba(255,255,255,.72);
}

.dashboard-hero-metrics strong {
  display: block;
  margin: 6px 0 4px;
  font-size: 20px;
}

.dashboard-hero-metrics em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.dashboard-stats {
  grid-template-columns: repeat(6, minmax(150px, 1fr));
}

.stat-card, .panel, .table-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat-card {
  padding: 16px;
  min-height: 108px;
}

.stat-card span { color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; margin-top: 10px; font-size: 28px; line-height: 1; }
.stat-card small { display: block; margin-top: 12px; color: var(--muted); }
.stat-card.blue { border-top: 3px solid var(--primary); }
.stat-card.green { border-top: 3px solid var(--green); }
.stat-card.amber { border-top: 3px solid var(--amber); }
.stat-card.teal { border-top: 3px solid var(--teal); }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
  gap: 16px;
}

.dashboard-chart-panel {
  min-width: 0;
}

.dashboard-trend {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 18px;
  align-items: stretch;
}

.dashboard-trend > div > strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 13px;
}

.trend-side,
.health-list,
.dashboard-activity {
  display: grid;
  gap: 10px;
}

.trend-list {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.trend-list h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

.trend-list p {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 6px 0;
  color: var(--muted);
  font-size: 12px;
}

.trend-list strong {
  color: var(--text);
}

.dashboard-health {
  min-width: 0;
}

.progress-row {
  margin-bottom: 14px;
}

.progress-row div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 13px;
}

.progress-row i {
  display: block;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef6;
}

.progress-row b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.progress-row.green b { background: var(--green); }
.progress-row p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }

.health-list div {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 4px 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.health-list strong {
  grid-row: span 2;
  color: var(--primary);
  font-size: 24px;
}

.health-list span {
  font-weight: 700;
}

.health-list em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.dashboard-wide {
  grid-column: 1 / -1;
}

.dashboard-activity {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 76px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8fafc;
  font-size: 13px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 16px;
}

.panel { padding: 16px; }
.panel-head, .toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h3, .table-title h3 { margin: 0; font-size: 16px; }
.panel-head p, .table-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.chart-bars {
  display: grid;
  grid-template-columns: repeat(12, minmax(16px, 1fr));
  align-items: end;
  gap: 8px;
  height: 230px;
  padding: 12px 4px 0;
}

.bar {
  min-height: 10px;
  border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, #1769e0, #0b8793);
  position: relative;
}

.bar span {
  position: absolute;
  left: 50%;
  bottom: -24px;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 11px;
}

.todo-list { display: grid; gap: 10px; }
.todo-item {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  border-bottom: 1px solid var(--line);
}
.todo-item:last-child { border-bottom: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.todo-item strong { display: block; font-size: 14px; }
.todo-item span { color: var(--muted); font-size: 12px; }
.todo-item em { color: var(--amber); font-style: normal; font-size: 12px; }

.table-panel {
  overflow: hidden;
}

.contract-filter-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-bottom: 10px;
  overflow-x: auto;
}

.contract-filter-tabs button {
  height: 34px;
  flex: 0 0 auto;
  padding: 0 12px;
  border-radius: 4px;
  color: #fff;
  background: var(--primary);
  font-weight: 700;
}

.contract-filter-tabs button.active {
  background: #ff7043;
}

.active-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.active-filter-bar span {
  color: var(--muted);
  font-size: 13px;
}

.active-filter-bar strong {
  color: var(--text);
}

.link-cell-btn {
  padding: 0;
  color: var(--primary);
  background: transparent;
  font-weight: 700;
}

.link-cell-btn:hover {
  text-decoration: underline;
}

.table-sort-btn {
  padding: 0;
  color: var(--primary);
  background: transparent;
  font-weight: 700;
}

.toolbar {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  margin: 0;
}

.table-title { min-width: 180px; }
.filters {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.filters input, .filters select {
  width: 190px;
  height: 38px;
}

.keyword-search {
  position: relative;
  width: 190px;
}

.keyword-search input {
  width: 100%;
}

.keyword-suggest {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 70;
  width: 340px;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .18);
}

.keyword-suggest button {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  text-align: left;
}

.keyword-suggest button:hover {
  background: #eef4fb;
}

.keyword-suggest button:last-child {
  border-bottom: 0;
}

.keyword-suggest strong {
  font-size: 13px;
}

.keyword-suggest span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.keyword-suggest em {
  color: var(--primary);
  font-style: normal;
  font-weight: 700;
}

.keyword-suggest-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

.filters .product-filter-select {
  width: 160px;
}

.filters .primary-btn {
  width: auto;
  min-width: 120px;
}

.compact-btn {
  padding: 0 12px;
}

.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-weight: 700;
  background: var(--surface-soft);
}

td .muted { color: var(--muted); }
.empty-cell { text-align: center; color: var(--muted); padding: 38px; }

.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 5px;
  font-size: 12px;
  background: #eef4fb;
  color: #36506d;
}
.tag.green { background: #e7f7f0; color: var(--green); }
.tag.amber { background: #fff5df; color: var(--amber); }
.tag.red { background: #fff0f0; color: var(--red); }
.tag.blue { background: #eaf2ff; color: var(--primary); }

.status-btn {
  height: 24px;
  padding: 0 9px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
  background: #eef4fb;
  color: #36506d;
}

.status-btn.amber { background: #fff5df; color: var(--amber); }
.status-btn.green { background: #e7f7f0; color: var(--green); }
.status-btn.red { background: #fff0f0; color: var(--red); }
.status-btn.blue { background: #eaf2ff; color: var(--primary); }

.contract-status-menu {
  position: fixed;
  z-index: 95;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 22px 46px rgba(15, 23, 42, .20);
}

.contract-status-menu-title {
  padding: 4px 8px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.contract-status-menu button {
  width: 100%;
  min-height: 46px;
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 2px 9px;
  align-items: center;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
}

.contract-status-menu button i {
  width: 8px;
  height: 8px;
  grid-row: 1 / span 2;
  border-radius: 999px;
  background: var(--muted);
}

.contract-status-menu button span {
  font-size: 13px;
  font-weight: 700;
}

.contract-status-menu button small {
  color: var(--muted);
  font-size: 11px;
}

.contract-status-menu button[data-status-option="approved"] i {
  background: var(--green);
}

.contract-status-menu button[data-status-option="shipped"] i {
  background: var(--primary);
}

.contract-status-menu button:hover {
  color: var(--primary);
  background: #eef4fb;
}

.contract-product-preview {
  position: fixed;
  z-index: 90;
  max-height: 420px;
  overflow: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 52px rgba(15, 23, 42, .22);
}

[data-contract-preview-trigger] {
  color: var(--primary);
  font-weight: 700;
  cursor: help;
}

.contract-preview-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #f8fbff, #fff);
}

.contract-preview-head strong {
  display: block;
  color: var(--text);
  font-size: 14px;
}

.contract-preview-head span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.contract-preview-head em {
  flex: 0 0 auto;
  height: 24px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  color: var(--primary);
  background: #eaf2ff;
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
}

.contract-preview-empty {
  margin: 0;
  padding: 18px 14px;
  color: var(--muted);
  font-size: 13px;
}

.contract-preview-list {
  display: grid;
  gap: 0;
}

.contract-preview-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.contract-preview-item span {
  display: block;
  color: var(--text);
  font-weight: 700;
}

.contract-preview-item em {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  white-space: normal;
}

.contract-preview-item dl {
  min-width: 156px;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 4px 8px;
  margin: 0;
  font-size: 12px;
}

.contract-preview-item dt {
  color: var(--muted);
}

.contract-preview-item dd {
  margin: 0;
  color: var(--text);
  text-align: right;
  font-weight: 700;
}

.contract-preview-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: #f8fafc;
}

.contract-preview-foot span {
  color: var(--muted);
  font-size: 12px;
}

.contract-preview-foot strong {
  color: var(--primary);
  font-size: 15px;
}

.product-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.row-actions button {
  height: 28px;
  border-radius: 5px;
  padding: 0 8px;
  color: var(--primary);
  background: #eef4fb;
}

.row-actions .danger-action {
  color: #fff;
  background: var(--red);
}

.category-panel .primary-btn {
  width: auto;
}

.category-tools .ghost-btn.active {
  color: #fff;
  border-color: #ff7b42;
  background: #ff7b42;
}

.category-table {
  min-width: 680px;
}

.category-table th:last-child,
.category-table td:last-child {
  width: 340px;
  text-align: center;
}

.category-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  color: var(--text);
}

.category-title.root {
  font-weight: 700;
}

.category-title.child {
  padding-left: 30px;
}

.category-title em {
  color: #111827;
  font-style: normal;
}

.category-actions {
  justify-content: center;
}

.category-actions button[data-category-action="addChild"] {
  color: #fff;
  background: var(--teal);
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.profile-avatar {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, #1769e0, #0b8793);
}

.profile-card strong {
  display: block;
  font-size: 16px;
}

.profile-card span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.profile-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.profile-info-grid div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.profile-info-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.profile-info-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 14px;
}

.profile-password {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.profile-password h4 {
  margin: 0 0 12px;
  font-size: 15px;
}

.system-config-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.system-config-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.system-config-form label {
  margin: 0;
}

.system-config-form small {
  color: var(--muted);
  font-size: 12px;
}

.system-config-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.system-config-actions .primary-btn,
.system-config-actions .ghost-btn {
  width: auto;
  min-width: 110px;
}

.system-config-preview {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.system-config-preview > span {
  color: var(--muted);
  font-size: 12px;
}

.preview-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 8px;
  background: #132844;
}

.preview-brand strong {
  display: block;
  color: #fff;
}

.preview-brand small {
  display: block;
  margin-top: 4px;
  color: #9fb0c4;
}

.preview-footer,
.preview-user {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.preview-footer em,
.preview-user span {
  display: block;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  text-transform: uppercase;
}

.preview-footer strong,
.preview-user strong {
  display: block;
  margin-top: 6px;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.contract-summary-bar {
  min-height: 34px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.contract-summary-bar span,
.contract-summary-bar strong {
  height: 28px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  padding: 0 10px;
  background: var(--surface-soft);
}

.contract-summary-bar strong {
  color: var(--text);
  font-weight: 700;
}

.contract-summary-bar .debt {
  color: var(--primary);
  background: #eef5ff;
}

.pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
}

.pagination button {
  height: 34px;
  min-width: 32px;
  border-radius: 5px;
  border: 1px solid var(--line);
  padding: 0 10px;
  background: #fff;
  color: var(--text);
  line-height: 32px;
}

.pagination button.active {
  color: #fff;
  border-color: var(--primary);
  background: var(--primary);
  font-weight: 700;
}

.pagination button:disabled {
  color: #a8b3c2;
  cursor: not-allowed;
  background: #f8fafc;
}

.pagination-total {
  margin-right: 4px;
  white-space: nowrap;
}

.page-number-list {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.page-ellipsis {
  min-width: 18px;
  color: #94a3b8;
  text-align: center;
}

.page-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  white-space: nowrap;
}

.page-jump input {
  width: 56px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  text-align: center;
  line-height: 32px;
  background: #fff;
}

.page-jump-group {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(16, 32, 51, .32);
  z-index: 10;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 100vw);
  max-width: 100vw;
  z-index: 11;
  background: #fff;
  box-shadow: -18px 0 50px rgba(24, 39, 75, .2);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.drawer.contract-drawer,
.drawer.wide-drawer {
  left: 264px;
  width: calc(100vw - 264px);
  max-width: none;
  box-shadow: -10px 0 34px rgba(24, 39, 75, .16);
}

.drawer.wide-drawer header {
  padding: 18px 28px 14px;
}

.drawer header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.drawer h3 { margin: 0 0 4px; font-size: 18px; }
.drawer p { margin: 0; color: var(--muted); font-size: 12px; }

.drawer-form {
  overflow: auto;
  padding: 18px;
  min-width: 0;
}

.drawer.wide-drawer .drawer-form {
  padding: 22px 28px;
}

.drawer.wide-drawer .drawer-actions {
  margin: 22px -28px -22px;
  padding: 14px 28px;
}

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

.form-grid .full { grid-column: 1 / -1; }

.contract-order-form {
  display: grid;
  gap: 16px;
  max-width: 1480px;
  margin: 0 auto;
}

.quote-form {
  display: grid;
  gap: 16px;
  max-width: 1480px;
  margin: 0 auto;
}

.drawer.smart-order-drawer {
  width: min(780px, calc(100vw - 24px));
}

.smart-order-panel {
  display: grid;
  gap: 14px;
}

.smart-order-panel textarea {
  min-height: 132px;
  resize: vertical;
}

.smart-voice-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
}

.smart-voice-row .ghost-btn {
  flex: 0 0 auto;
}

.smart-voice-row .ghost-btn.listening {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fef2f2;
}

.smart-voice-row span {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.smart-order-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.smart-order-examples button {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--primary);
  background: #f8fafc;
  font-weight: 700;
}

.smart-order-preview:empty {
  display: none;
}

.smart-preview-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

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

.smart-preview-head span {
  padding: 4px 8px;
  border-radius: 999px;
  color: #075985;
  background: #e0f2fe;
  font-size: 12px;
  font-weight: 700;
}

.smart-preview-grid {
  display: grid;
  grid-template-columns: minmax(180px, .75fr) minmax(0, 1.25fr);
  gap: 14px;
  padding: 14px;
}

.smart-preview-grid h4 {
  margin: 0 0 10px;
  font-size: 14px;
}

.smart-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.smart-option + .smart-option {
  margin-top: 8px;
}

.smart-option input {
  width: auto;
  margin-top: 3px;
}

.smart-option span {
  display: grid;
  gap: 2px;
}

.smart-option em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.smart-product-list {
  display: grid;
  gap: 8px;
}

.smart-product-row {
  display: grid;
  grid-template-columns: minmax(150px, .75fr) minmax(180px, 1.25fr);
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.smart-product-row strong,
.smart-product-row span {
  display: block;
}

.smart-product-row span,
.smart-product-row em,
.smart-empty {
  color: var(--muted);
  font-size: 12px;
}

.smart-product-row.unresolved {
  grid-template-columns: 1fr auto auto;
  border-color: #fed7aa;
  background: #fff7ed;
}

.contract-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 16px;
}

.contract-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
}

.contract-form-grid .full {
  grid-column: 1 / -1;
}

.contract-form-grid b {
  color: var(--red);
}

.receipt-form b {
  color: var(--red);
}

.receipt-form input[readonly] {
  background: #f8fafc;
  color: #475569;
}

.invoice-panel {
  display: grid;
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
}

.invoice-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.invoice-summary div {
  min-width: 0;
  display: grid;
  gap: 5px;
  padding-right: 12px;
  border-right: 1px solid var(--line);
}

.invoice-summary div:last-child {
  border-right: 0;
  padding-right: 0;
}

.invoice-summary span {
  color: var(--muted);
  font-size: 12px;
}

.invoice-summary strong {
  min-width: 0;
  color: var(--text);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.drawer.finance-drawer .invoice-form,
.drawer.finance-drawer .issuer-title-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.drawer.quote-drawer .contract-form-grid {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

/* Keep quotation product entry in the working area instead of below a long form. */
.drawer.quote-drawer header {
  padding: 12px 28px 10px;
}

.drawer.quote-drawer .drawer-form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  overflow: hidden;
  padding: 14px 28px 0;
}

.drawer.quote-drawer .quote-form {
  display: contents;
  max-width: none;
}

.drawer.quote-drawer .contract-card {
  padding: 12px 14px;
}

.drawer.quote-drawer .contract-form-grid {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px 12px;
}

.drawer.quote-drawer .contract-form-grid label:has([data-quote-customer]) {
  grid-column: span 2;
}

.drawer.quote-drawer .contract-form-grid textarea {
  min-height: 54px;
}

.drawer.quote-drawer .quote-lines {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.drawer.quote-drawer .quote-lines .table-wrap {
  flex: 1;
  min-height: 260px;
  overflow: auto;
}

.drawer.quote-drawer .quote-lines-table {
  min-width: 1320px;
}

.drawer.quote-drawer .product-search-cell {
  min-width: 260px;
}

.drawer.quote-drawer .contract-lines-table .product-search-cell input[data-line-product-search] {
  width: 260px;
}

.drawer.quote-drawer .quote-lines-table input[data-line-desc],
.drawer.quote-drawer .quote-lines-table input[data-line-remark] {
  min-width: 190px;
}

.drawer.quote-drawer .quote-lines-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  box-shadow: 0 1px 0 var(--line);
}

.drawer.quote-drawer .drawer-actions {
  position: relative;
  bottom: auto;
  z-index: 3;
  margin: 0 -28px;
  padding: 14px 28px;
  box-shadow: 0 -8px 18px rgba(15, 23, 42, .06);
}

/* Contract editing uses the same roomy working area as quotation editing. */
.drawer.contract-drawer header {
  padding: 12px 28px 10px;
}

.drawer.contract-drawer .drawer-form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  overflow: hidden;
  padding: 14px 28px 0;
}

.drawer.contract-drawer .contract-order-form {
  display: contents;
  max-width: none;
}

.drawer.contract-drawer .contract-card {
  padding: 12px 14px;
}

.drawer.contract-drawer .contract-form-grid {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px 12px;
}

.drawer.contract-drawer .contract-form-grid label:has([data-contract-customer]) {
  grid-column: span 2;
}

.drawer.contract-drawer .contract-form-grid textarea {
  min-height: 54px;
}

.drawer.contract-drawer .contract-lines {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.drawer.contract-drawer .contract-lines .table-wrap {
  flex: 1;
  min-height: 300px;
  overflow: auto;
}

.drawer.contract-drawer .contract-lines-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  box-shadow: 0 1px 0 var(--line);
}

.drawer.contract-drawer .drawer-actions {
  position: relative;
  bottom: auto;
  z-index: 3;
  margin: 0 -28px;
  padding: 14px 28px;
  box-shadow: 0 -8px 18px rgba(15, 23, 42, .06);
}

.invoice-form b,
.issuer-title-form b {
  color: var(--red);
}

.checkbox-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--text);
}

.checkbox-line input {
  width: 16px;
  height: 16px;
}

.checkbox-line input:disabled + span {
  color: var(--muted);
}

.save-title-tip {
  flex-basis: 100%;
  padding-left: 24px;
  color: var(--muted);
  font-size: 12px;
}

.save-title-tip.ok {
  color: var(--green);
}

.save-title-tip.locked {
  color: var(--amber);
}

.issuer-title-layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
}

.issuer-title-list {
  display: grid;
  gap: 10px;
}

.issuer-title-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.issuer-title-card strong,
.issuer-title-card span,
.issuer-title-card small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.issuer-title-card strong {
  color: var(--text);
}

.issuer-title-card span,
.issuer-title-card small {
  color: var(--muted);
  font-size: 12px;
}

.issuer-title-card div {
  grid-row: 1 / span 3;
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 8px;
}

.empty-title {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.customer-invoice-title-head {
  max-width: 1180px;
  margin: 0 auto 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  display: grid;
  gap: 5px;
}

.customer-invoice-title-head strong {
  font-size: 16px;
}

.customer-invoice-title-head span {
  color: var(--muted);
  font-size: 13px;
}

.contract-print-tools {
  max-width: 1180px;
  margin: 0 auto 14px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.contract-print-tools label {
  min-width: min(420px, 100%);
  margin: 0;
}

.contract-print-tools span {
  color: var(--muted);
  font-size: 13px;
}

.print-contract-paper {
  max-width: 860px;
  min-height: 1120px;
  margin: 0 auto;
  padding: 42px 50px;
  border: 1px solid #d7dee8;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, .12);
  outline: none;
}

.print-contract-paper:focus {
  box-shadow: 0 0 0 3px rgba(23, 105, 224, .12), 0 16px 36px rgba(15, 23, 42, .12);
}

.contract-doc {
  color: #000;
  font-family: SimSun, "宋体", serif;
  font-size: 13px;
  line-height: 1.65;
}

.contract-doc-top {
  position: relative;
  min-height: 50px;
  margin: 0 0 8px;
}

.contract-doc-top h2 {
  margin: 0;
  padding-top: 8px;
  text-align: center;
  font-size: 20px;
}

.contract-doc .contract-no {
  position: absolute;
  top: 38px;
  right: 0;
  margin: 0;
  font-size: 13px;
}

.contract-doc p {
  margin: 7px 0;
}

.contract-doc table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.contract-doc th,
.contract-doc td {
  border: 1px solid #000;
  padding: 5px 6px;
  vertical-align: middle;
  word-break: break-word;
}

.contract-doc th {
  text-align: center;
  font-weight: 700;
}

.print-product-table th:nth-child(1) { width: 42px; }
.print-product-table th:nth-child(2) { width: 150px; }
.print-product-table th:nth-child(3) { width: 128px; }
.print-product-table th:nth-child(4) { width: 48px; }
.print-product-table th:nth-child(5) { width: 48px; }
.print-product-table th:nth-child(6) { width: 76px; }
.print-product-table th:nth-child(7) { width: 86px; }

.print-product-table td {
  text-align: center;
}

.print-product-table td:nth-child(2),
.print-product-table td:nth-child(3),
.print-product-table td:nth-child(8) {
  text-align: left;
}

.print-total-row td {
  font-weight: 700;
}

.print-sign-table {
  margin-top: 14px;
}

.print-sign-table td {
  width: 50%;
  min-height: 150px;
}

.invoice-contract-preview {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  max-width: 1180px;
  margin: 0 auto;
  overflow: hidden;
}

.invoice-contract-preview h2 {
  margin: 0 0 18px;
  text-align: center;
  font-size: 22px;
}

.invoice-contract-preview table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.invoice-contract-preview th,
.invoice-contract-preview td {
  border: 1px solid #1f2937;
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.invoice-contract-preview th {
  width: 118px;
  background: #eef4fb;
  font-weight: 700;
}

.invoice-base-table th {
  color: #506078;
}

.invoice-detail-title {
  margin-top: 10px;
  border: 1px solid #1f2937;
  border-bottom: 0;
  padding: 7px 10px;
  text-align: center;
  color: #e11d48;
  font-size: 18px;
  font-weight: 700;
}

.invoice-detail-table {
  table-layout: fixed;
}

.invoice-detail-table th,
.invoice-detail-table td {
  text-align: center;
}

.invoice-detail-table th {
  width: auto;
  color: #e11d48;
  background: #fff;
  font-size: 15px;
}

.invoice-detail-table th:nth-child(1) { width: 74px; }
.invoice-detail-table th:nth-child(2) { width: 150px; }
.invoice-detail-table th:nth-child(3) { width: auto; }
.invoice-detail-table th:nth-child(4) { width: 70px; }
.invoice-detail-table th:nth-child(5) { width: 88px; }
.invoice-detail-table th:nth-child(6) { width: 120px; }
.invoice-detail-table th:nth-child(7) { width: 130px; }
.invoice-detail-table th:nth-child(8) { width: 170px; }

.invoice-detail-table td:nth-child(3) {
  text-align: left;
}

.invoice-empty-detail {
  height: 58px;
  color: var(--muted);
}

.invoice-total-row td {
  font-weight: 700;
}

.invoice-total-row td:first-child {
  text-align: center;
}

.quote-preview-paper {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: auto;
}

.quote-sheet {
  min-width: 1078px;
  color: #111827;
}

.quote-sheet table {
  width: 1078px;
  border-collapse: collapse;
  table-layout: fixed;
}

.quote-export-table th,
.quote-export-table td {
  border: 1px solid #1f2937;
  padding: 8px 10px;
  vertical-align: middle;
  text-align: center;
  overflow-wrap: anywhere;
}

.quote-export-table th {
  background: #edf3fb;
  color: #1f2937;
  font-weight: 700;
}

.quote-title-row td {
  height: 46px;
  border: 0;
  color: #0f2d52;
  font-size: 26px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0;
}

.quote-gap-row td {
  height: 12px;
  border: 0;
  padding: 0;
}

.quote-head-row th {
  background: #dbeafe;
}

.quote-left {
  text-align: left !important;
}

.quote-center {
  text-align: center !important;
}

.quote-money {
  text-align: right !important;
}

.quote-total-row td {
  font-weight: 700;
  background: #f8fafc;
}

.quote-total-row td:first-child {
  text-align: center;
}

.quote-note-row td {
  height: 28px;
}

.quote-note-title {
  text-align: center;
  font-weight: 700;
  background: #edf3fb;
}

.quote-note-text {
  text-align: left !important;
}

.select-col {
  width: 42px;
  text-align: center !important;
}

.select-col input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.batch-lines {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  max-width: 1180px;
  margin-left: auto;
  margin-right: auto;
}

.batch-lines h4 {
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.batch-lines table {
  width: 100%;
  border-collapse: collapse;
}

.batch-lines th,
.batch-lines td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.batch-lines tr:last-child td {
  border-bottom: 0;
}

.contract-lines {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.contract-lines-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.contract-lines-head .vat-flag {
  margin-left: auto;
  font-size: 13px;
}

.product-name-head {
  min-width: 290px;
  vertical-align: top;
}

.line-add-product-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 32px;
  margin-top: 7px;
  padding: 0 10px;
  border: 1px solid #b9d3f6;
  border-radius: 4px;
  color: var(--primary);
  background: #eff6ff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.line-add-product-btn:hover {
  border-color: #8fbaf2;
  background: #dbeafe;
}

.contract-lines-table {
  min-width: 1240px;
}

.quote-lines-table {
  min-width: 1380px;
}

.contract-lines-table th,
.contract-lines-table td {
  padding: 9px 8px;
  text-align: center;
}

.contract-lines-table input {
  height: 32px;
  min-width: 76px;
  padding: 6px 8px;
  border-color: #d8dde6;
  border-radius: 4px;
  text-align: center;
}

.contract-lines-table input[data-line-content] {
  min-width: 180px;
  text-align: left;
}

.quote-lines-table input[data-line-desc],
.quote-lines-table input[data-line-remark] {
  min-width: 220px;
  text-align: left;
}

.contract-lines-table input[readonly] {
  background: #f8fafc;
  color: #475569;
}

.product-search-cell {
  position: relative;
  min-width: 290px;
}

.contract-lines-table .product-search-cell input[data-line-product-search] {
  width: 290px;
  text-align: left;
}

.product-suggest-list {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 9999;
  width: min(520px, 92vw);
  max-height: min(560px, 72vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .20);
  text-align: left;
}

.product-suggest-list button {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  text-align: left;
}

.product-suggest-list button:hover {
  background: #eef4fb;
}

.product-suggest-list button:last-child {
  border-bottom: 0;
}

.product-suggest-list strong {
  font-size: 13px;
  line-height: 1.35;
}

.product-suggest-list span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.product-suggest-list em {
  color: var(--primary);
  font-style: normal;
  font-weight: 700;
}

.product-suggest-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

.category-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.category-select {
  display: grid;
  gap: 6px;
}

.category-select small {
  color: var(--muted);
  font-size: 12px;
}

.image-upload-row {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 12px;
  align-items: center;
}

.image-preview {
  width: 76px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-field input[type="file"] {
  display: none;
}

.image-field small {
  display: block;
  color: var(--muted);
  margin-top: 8px;
  font-size: 12px;
}

.drawer-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 18px -18px -18px;
  padding: 14px 18px;
  background: #fff;
  border-top: 1px solid var(--line);
}

.drawer-actions .primary-btn { width: auto; min-width: 96px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  min-width: 220px;
  max-width: min(520px, 88vw);
  padding: 12px 16px;
  border-radius: 6px;
  background: #102033;
  color: #fff;
  z-index: 20;
  box-shadow: var(--shadow);
  text-align: center;
}

@media (max-width: 980px) {
  .login-view { grid-template-columns: 1fr; gap: 28px; }
  .main-view { grid-template-columns: 84px minmax(0, 1fr); }
  .sidebar { padding: 14px 10px; }
  .sidebar-brand {
    justify-content: center;
    padding: 10px;
  }
  .sidebar-brand div:not(.brand-mark),
  .nav-item span:not(.nav-icon),
  .nav-badge,
  .nav-section-title,
  .sidebar-footer { display: none; }
  .nav-item {
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 0;
  }
  .nav-item:hover { transform: none; }
  .nav-icon { width: 34px; height: 34px; }
  .nav-menu { padding-bottom: 0; }
  .nav-children { display: none; }
  .stats-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .dashboard-hero { grid-template-columns: 1fr; }
  .dashboard-hero-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-stats { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-trend { grid-template-columns: 1fr; }
  .dashboard-activity { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .system-config-layout { grid-template-columns: 1fr; }
  .drawer.contract-drawer,
  .drawer.wide-drawer {
    left: 84px;
    width: calc(100vw - 84px);
  }
  .drawer.finance-drawer .invoice-form,
  .drawer.finance-drawer .issuer-title-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .issuer-title-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  body { overflow-x: hidden; }
  .login-view {
    grid-template-columns: 1fr;
    padding: 24px 16px;
  }
  .login-brand {
    align-items: flex-start;
    gap: 14px;
  }
  .login-brand h1 { font-size: 26px; }
  .main-view {
    display: block;
    min-height: 100vh;
  }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 9;
    min-height: auto;
    height: auto;
    padding: 10px 10px 8px;
    overflow: hidden;
    border-right: 0;
    border-bottom: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 12px 26px rgba(15, 23, 42, .16);
  }
  .sidebar-brand {
    min-height: 48px;
    margin-bottom: 8px;
    padding: 8px;
  }
  .sidebar-brand div:not(.brand-mark) {
    display: block;
  }
  .sidebar-brand strong { font-size: 14px; }
  .sidebar-brand span { font-size: 11px; margin-top: 2px; }
  .brand-mark.small {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    font-size: 12px;
  }
  .nav-menu {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 0 0 4px;
    scrollbar-width: none;
  }
  .nav-menu::-webkit-scrollbar { display: none; }
  .nav-group {
    flex: 0 0 auto;
    display: block;
  }
  .nav-section-title,
  .nav-badge,
  .sidebar-footer {
    display: none;
  }
  .nav-item {
    width: auto;
    min-width: 82px;
    height: 38px;
    display: inline-flex;
    justify-content: center;
    gap: 6px;
    padding: 0 10px;
    white-space: nowrap;
  }
  .nav-item::before { display: none; }
  .nav-icon {
    width: 26px;
    height: 26px;
    font-size: 12px;
  }
  .nav-item span:not(.nav-icon) {
    display: inline;
    font-size: 13px;
  }
  .nav-children {
    display: none !important;
  }
  .content { padding: 0 12px 24px; }
  .topbar {
    min-height: auto;
    align-items: flex-start;
    padding: 12px 0;
    gap: 10px;
  }
  .topbar h2 { font-size: 20px; }
  .topbar p { font-size: 12px; }
  .top-actions {
    align-self: flex-start;
    gap: 6px;
  }
  .icon-btn { width: 34px; height: 34px; }
  .user-chip {
    height: 34px;
    gap: 6px;
    padding-left: 8px;
  }
  .user-chip span { max-width: 72px; }
  .user-chip button {
    height: 26px;
    padding: 0 8px;
  }
  .page-body { padding-top: 12px; }
  .stats-grid { grid-template-columns: 1fr; }
  .dashboard-hero-metrics,
  .dashboard-stats,
  .dashboard-activity {
    grid-template-columns: 1fr;
  }
  .toolbar { align-items: flex-start; flex-direction: column; }
  .filters { width: 100%; justify-content: stretch; }
  .filters input, .filters select, .filters button { width: 100%; }
  .table-panel {
    border-radius: 8px;
  }
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-footer {
    align-items: stretch;
    flex-direction: column;
  }
  .contract-summary-bar {
    align-items: stretch;
  }
  .contract-summary-bar span,
  .contract-summary-bar strong {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
  }
  .pagination {
    justify-content: flex-start;
  }
  .pagination-total {
    width: 100%;
  }
  .page-number-list {
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  table {
    min-width: 920px;
  }
  .row-actions {
    flex-wrap: nowrap;
  }
  .row-actions button {
    min-width: 50px;
  }
  .section-tabs { display: flex; width: 100%; }
  .section-tabs button { flex: 1; min-width: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .profile-info-grid { grid-template-columns: 1fr; }
  .system-config-form { grid-template-columns: 1fr; }
  .system-config-actions { justify-content: stretch; }
  .system-config-actions .primary-btn,
  .system-config-actions .ghost-btn {
    flex: 1;
    min-width: 0;
  }
  .contract-form-grid { grid-template-columns: 1fr; }
  .drawer.contract-drawer,
  .drawer.wide-drawer {
    left: 0;
    width: 100vw;
  }
  .drawer {
    width: 100vw;
  }
  .drawer.smart-order-drawer {
    width: 100vw;
  }
  .drawer-form { padding: 12px; }
  .drawer.wide-drawer header { padding: 14px 12px; }
  .drawer.wide-drawer .drawer-form { padding: 12px; }
  .drawer.wide-drawer .drawer-actions {
    margin: 14px -12px -12px;
    padding: 12px;
  }
  .drawer.quote-drawer .drawer-form {
    display: block;
    overflow: auto;
    padding: 12px;
  }
  .drawer.quote-drawer .quote-form {
    display: grid;
  }
  .drawer.quote-drawer .contract-form-grid {
    grid-template-columns: 1fr;
  }
  .drawer.quote-drawer .contract-form-grid label:has([data-quote-customer]) {
    grid-column: auto;
  }
  .drawer.quote-drawer .quote-lines .table-wrap {
    min-height: 310px;
  }
  .drawer.quote-drawer .drawer-actions {
    position: sticky;
    bottom: 0;
    margin: 14px -12px -12px;
    padding: 12px;
    box-shadow: 0 -8px 18px rgba(15, 23, 42, .06);
  }
  .drawer.contract-drawer .drawer-form {
    display: block;
    overflow: auto;
    padding: 12px;
  }
  .drawer.contract-drawer .contract-order-form {
    display: grid;
    max-width: none;
  }
  .drawer.contract-drawer .contract-form-grid {
    grid-template-columns: 1fr;
  }
  .drawer.contract-drawer .contract-form-grid label:has([data-contract-customer]) {
    grid-column: auto;
  }
  .drawer.contract-drawer .contract-lines .table-wrap {
    min-height: 310px;
  }
  .drawer.contract-drawer .drawer-actions {
    position: sticky;
    bottom: 0;
    margin: 14px -12px -12px;
    padding: 12px;
    box-shadow: 0 -8px 18px rgba(15, 23, 42, .06);
  }
  .drawer.finance-drawer .invoice-form,
  .drawer.finance-drawer .issuer-title-form,
  .invoice-summary {
    grid-template-columns: 1fr;
  }
  .invoice-summary div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 0 10px;
  }
  .invoice-summary div:last-child {
    border-bottom: 0;
    padding-bottom: 0;
  }
  .product-name-head { min-width: 260px; }
  .contract-order-form,
  .quote-form {
    max-width: none;
  }
  .smart-preview-grid,
  .smart-product-row {
    grid-template-columns: 1fr;
  }
  .smart-product-row.unresolved {
    grid-template-columns: 1fr;
  }
  .smart-order-examples button {
    flex: 1;
  }
  .contract-lines-table,
  .quote-lines-table {
    min-width: 1280px;
  }
  .product-suggest-list {
    left: 8px !important;
    width: calc(100vw - 16px) !important;
    max-height: 58vh !important;
  }
}

/* 产品参数 */
.product-param-product { display: flex; flex-direction: column; gap: 3px; }
.product-param-product strong { font-weight: 600; color: var(--text); }
.product-param-product em { color: var(--muted); font-style: normal; font-size: 12px; }
.product-param-file { display: flex; align-items: center; gap: 8px; }
.file-icon {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; height: 24px; padding: 0 6px;
  border-radius: 5px; background: #eef4fb; color: #36506d;
  font-size: 11px; font-weight: 700;
}
.product-param-file span:last-child { overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.form-tip { grid-column: 1 / -1; color: var(--muted); font-size: 12px; line-height: 1.6; margin: -4px 0 0; }

.file-preview-overlay {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(15, 23, 42, 0.78);
  display: flex; flex-direction: column;
  padding: 24px;
}
.file-preview-overlay.hidden { display: none; }
.file-preview-head {
  display: flex; align-items: center; justify-content: space-between;
  color: #fff; padding: 0 0 14px;
}
.file-preview-head > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.file-preview-head strong { font-size: 15px; }
.file-preview-head span { color: rgba(255,255,255,0.72); font-size: 12px; }
.file-preview-head .icon-btn { background: rgba(255,255,255,0.12); color: #fff; border-color: rgba(255,255,255,0.22); }
.file-preview-body {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; overflow: hidden; background: #fff;
}
.file-preview-body.image img { max-width: 100%; max-height: 100%; object-fit: contain; }
.file-preview-body.pdf iframe { width: 100%; height: 100%; border: 0; }
.file-preview-body.text pre {
  width: 100%; height: 100%; margin: 0; padding: 20px; overflow: auto;
  white-space: pre-wrap; font: 13px/1.6 monospace; color: #1f2937;
}
.file-preview-body.unsupported { flex-direction: column; gap: 16px; color: #64748b; }
.file-preview-body.unsupported p { font-size: 14px; margin: 0; }
.file-preview-body.unsupported .primary-btn { width: auto; min-width: 120px; }
