:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #eef3f6;
  --surface-table-head: #f1f6f8;
  --ink: #101828;
  --muted: #5d6979;
  --line: #d7dee7;
  --line-soft: #e5ebf1;
  --line-strong: #b9c5d0;
  --teal: #006b67;
  --teal-dark: #045853;
  --rose: #b01e55;
  --amber: #a45a08;
  --blue: #2563eb;
  --red: #b91c1c;
  --green-soft: #e1f3ee;
  --rose-soft: #fde7ef;
  --amber-soft: #fff4d6;
  --blue-soft: #e9f1ff;
  --shadow: 0 10px 24px rgba(16, 24, 40, 0.08);
  --shadow-soft: 0 1px 3px rgba(16, 24, 40, 0.06);
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #f8fafb 0, #f4f6f8 260px),
    var(--bg);
  color: var(--ink);
  font: 13px/1.42 "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12);
}

label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

h3 {
  font-size: 15px;
}

img,
video {
  display: block;
  max-width: 100%;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 26px;
  background:
    radial-gradient(circle at 20% 18%, rgba(0, 107, 103, 0.10), transparent 34%),
    linear-gradient(135deg, rgba(0, 107, 103, 0.08), rgba(37, 99, 235, 0.05)),
    var(--bg);
}

.login-shell {
  width: min(1140px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 14px;
  align-items: stretch;
}

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

.login-copy {
  min-height: 520px;
  padding: 24px;
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: hidden;
}

.login-copy p:last-child {
  color: var(--muted);
  max-width: 620px;
}

.login-video-grid {
  height: min(46vh, 360px);
  min-height: 280px;
  margin-top: 4px;
  overflow: hidden;
}

.login-panel {
  padding: 16px;
  align-self: start;
  min-height: 520px;
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.inline-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 8px;
  align-items: end;
}

.tabs,
.main-nav,
.segmented,
.button-row,
.head-actions,
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.my-menu {
  position: relative;
}

.my-menu summary {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--teal-dark);
  padding: 6px 10px;
  cursor: pointer;
  list-style: none;
  font-weight: 700;
}

.my-menu summary::-webkit-details-marker {
  display: none;
}

.my-menu summary::after {
  content: "⌄";
  margin-left: 7px;
  color: var(--muted);
}

.my-menu[open] summary {
  border-color: rgba(0, 107, 103, 0.28);
  box-shadow: 0 0 0 2px rgba(0, 107, 103, 0.08);
}

.my-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 28;
  min-width: 142px;
  display: grid;
  gap: 3px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.my-menu-list button {
  min-height: 30px;
  min-width: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  justify-content: flex-start;
  padding: 6px 8px;
}

.my-menu-list button:hover {
  background: var(--surface-2);
  color: var(--teal-dark);
}

.my-menu {
  display: none;
}

body[data-role="customer"] .my-menu,
body[data-role="customer_guest"] .my-menu,
body[data-role="sales"] .my-menu,
body[data-role="procurement"] .my-menu,
body[data-role="admin"] .my-menu {
  display: block;
}

.compact-tabs {
  background: var(--surface-2);
  padding: 3px;
  border-radius: 6px;
  border: 1px solid #e6edf1;
}

.tab,
.main-nav button,
.segmented button {
  border-radius: 6px;
  padding: 7px 12px;
  background: transparent;
  color: var(--muted);
}

.tab.is-active,
.main-nav button.is-active,
.segmented button.is-active {
  background: #fff;
  color: var(--teal-dark);
  box-shadow: var(--shadow-soft);
}

.primary,
.secondary,
.ghost,
.danger,
.file-button {
  min-height: 32px;
  border-radius: 5px;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.primary {
  background: var(--teal);
  color: #fff;
  border: 1px solid var(--teal);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset;
}

.secondary {
  background: #fff;
  color: var(--teal-dark);
  border: 1px solid var(--line);
}

.secondary:hover,
.ghost:hover,
.chip:hover {
  border-color: var(--line-strong);
  background: #f9fbfb;
}

.secondary.is-added {
  animation: addButtonPulse 720ms ease;
  background: var(--green-soft);
  border-color: rgba(15, 118, 110, 0.32);
}

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}

.danger {
  background: #fee2e2;
  color: var(--red);
  border: 1px solid #fecaca;
}

.file-button {
  position: relative;
  background: var(--blue);
  color: #fff;
  overflow: hidden;
  border: 1px solid var(--blue);
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.message {
  color: var(--teal-dark);
  min-height: 18px;
}

.message.error {
  color: var(--red);
}

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

.eyebrow {
  color: var(--teal-dark);
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  font-size: 12px;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.98);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar h1 {
  font-size: 17px;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--muted);
}

body[data-view="client"] .user-badge {
  color: var(--teal-dark);
  background: var(--green-soft);
  border-color: rgba(0, 107, 103, 0.22);
}

.main-nav {
  position: sticky;
  top: 48px;
  z-index: 19;
  padding: 4px 8px;
  background: rgba(248, 250, 251, 0.98);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.main-nav.is-hidden {
  display: none !important;
}

.main-nav button {
  min-width: 76px;
}

.main-nav[data-mode="internal"]::before {
  content: "内部工作台";
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  padding: 0 4px 0 2px;
  white-space: nowrap;
}

body[data-nav-mode="internal"] .app-shell {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  background: #f5f7f9;
}

body[data-nav-mode="internal"] .topbar {
  grid-column: 1 / -1;
  min-height: 50px;
  padding: 6px 12px;
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.02);
}

body[data-nav-mode="internal"] .main-nav {
  grid-column: 1;
  grid-row: 2;
  position: sticky;
  top: 50px;
  height: calc(100vh - 50px);
  align-self: start;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px 8px;
  overflow-x: hidden;
  overflow-y: auto;
  background: #fff;
  border-right: 1px solid var(--line);
  border-bottom: 0;
}

body[data-nav-mode="internal"] .main-nav::before {
  content: none;
}

body[data-nav-mode="internal"] main {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  padding: 10px 12px 78px;
}

body[data-nav-mode="internal"] .view {
  max-width: none;
  gap: 10px;
}

.nav-shell {
  display: grid;
  gap: 8px;
  width: 100%;
}

.nav-title {
  display: grid;
  gap: 2px;
  padding: 8px 8px 10px;
  border-bottom: 1px solid var(--line-soft);
}

.nav-title strong {
  font-size: 14px;
}

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

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

.nav-group:not(.is-active) .nav-children {
  display: none;
}

.nav-group.is-active {
  padding: 3px;
  border-radius: 6px;
  background: #f8fafb;
}

.nav-parent,
.nav-child {
  width: 100%;
  min-width: 0 !important;
  justify-content: flex-start;
  text-align: left;
  border-radius: 5px;
}

.nav-parent {
  min-height: 34px;
  padding: 7px 8px;
  color: var(--ink);
  background: transparent;
}

.nav-parent small {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
}

.nav-parent small::before {
  content: "›";
  margin-right: 5px;
  color: var(--line-strong);
}

.nav-parent.is-active small::before {
  content: "⌄";
  color: var(--teal-dark);
}

.nav-parent.is-active {
  background: #eef8f6;
  color: var(--teal-dark);
  font-weight: 700;
}

.nav-children {
  display: grid;
  gap: 2px;
  padding-left: 8px;
  margin-left: 8px;
  border-left: 1px solid var(--line-soft);
}

.nav-child {
  min-height: 28px;
  padding: 5px 8px;
  color: var(--muted);
  background: transparent;
}

.nav-child:hover,
.nav-parent:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav-child.is-active {
  background: #fff;
  color: var(--teal-dark);
  box-shadow: inset 2px 0 0 var(--teal);
  font-weight: 700;
}

body[data-nav-mode="internal"] .section-head {
  min-height: 54px;
  align-items: center;
  padding: 8px 10px;
  box-shadow: none;
}

body[data-nav-mode="internal"] .panel {
  box-shadow: none;
}

body[data-nav-mode="internal"] .split-grid,
body[data-nav-mode="internal"] .settings-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

body[data-nav-mode="internal"] #salesTables,
body[data-nav-mode="internal"] #procurementTables,
body[data-nav-mode="internal"] .sales-actions,
body[data-nav-mode="internal"] .procurement-actions {
  order: initial;
}

body[data-nav-mode="internal"] .settings-grid > .panel,
body[data-nav-mode="internal"] .settings-grid > .setting-form,
body[data-nav-mode="internal"] .settings-grid > .pricing-rule-panel {
  grid-column: 1 / -1;
}

body[data-nav-mode="internal"] .table-wrap table {
  font-size: 12px;
}

main {
  padding: 8px 8px 86px;
}

.view {
  display: grid;
  gap: 6px;
}

#client {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

#client > .section-head,
#client > .workflow-strip,
#client > #clientBasket,
#client > #client-inquiry {
  grid-column: 1 / -1;
}

#client > .toolbar,
#client > .chip-row,
#client > .bulk-bar,
#client > .product-list {
  grid-column: 1;
}

#client > .section-head { order: 1; }
#client > .workflow-strip { order: 2; }
#client > #clientBasket { order: 3; }
#client > .toolbar { order: 4; }
#client > .chip-row { order: 5; }
#client > .bulk-bar { order: 6; }
#client > .product-list { order: 7; }
#client > #client-inquiry { order: 8; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.section-head h2 {
  letter-spacing: 0;
}

.section-head p {
  color: var(--muted);
  margin-top: 2px;
}

.section-head.compact {
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
  margin-bottom: 10px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 112px 198px auto;
  gap: 5px;
  align-items: end;
  padding: 5px 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.workflow-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.workflow-step {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  box-shadow: var(--shadow-soft);
}

.workflow-step strong {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--teal-dark);
}

.workflow-step.is-active {
  border-color: rgba(0, 107, 103, 0.34);
  background: linear-gradient(180deg, #ffffff, #f3fbf9);
  color: var(--ink);
}

.workflow-step.is-done {
  border-color: rgba(0, 107, 103, 0.24);
  background: #f6fbfa;
  color: var(--teal-dark);
}

.basket-panel {
  min-height: 42px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  padding: 5px 9px;
  border-color: rgba(0, 107, 103, 0.18);
  background: linear-gradient(90deg, #ffffff 0, #f8fcfb 100%);
}

.basket-summary {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(128px, auto);
  align-items: center;
  gap: 10px;
}

.basket-copy {
  display: grid;
  gap: 1px;
}

.basket-copy strong {
  color: var(--teal-dark);
  font-size: 14px;
}

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

.basket-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.basket-metrics span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  white-space: nowrap;
}

.basket-metrics strong {
  color: var(--ink);
}

.basket-state {
  justify-self: end;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  white-space: nowrap;
}

.basket-state.is-ready {
  background: var(--green-soft);
  color: var(--teal-dark);
  font-weight: 700;
}

.basket-details {
  border-top: 1px solid rgba(0, 107, 103, 0.12);
  padding-top: 6px;
}

.basket-details summary {
  cursor: pointer;
  color: var(--teal-dark);
  font-weight: 700;
  margin-bottom: 6px;
}

.basket-table table {
  min-width: 900px;
}

.basket-table th,
.basket-table td {
  padding: 4px 6px;
}

.basket-table .qty-input,
.basket-table .target-input {
  max-width: 90px;
}

.range-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.toolbar label {
  gap: 3px;
}

.toolbar input,
.toolbar select {
  padding: 5px 7px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

#client > .chip-row {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

#client > .chip-row .chip {
  flex: 0 0 auto;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--line);
}

.chip.is-active {
  color: var(--teal-dark);
  background: var(--green-soft);
  border-color: rgba(15, 118, 110, 0.3);
}

.chip.special {
  color: var(--rose);
  background: var(--rose-soft);
  border-color: rgba(180, 35, 90, 0.25);
}

.bulk-bar {
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.checkline {
  display: inline-flex;
  grid-auto-flow: column;
  align-items: center;
  gap: 6px;
  color: var(--ink);
}

.checkline input {
  width: 14px;
  height: 14px;
}

.product-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
  background: var(--surface);
}

#productList table {
  min-width: 0;
  width: 100%;
  table-layout: fixed;
  font-size: 12px;
}

#productList .table-wrap {
  overflow-x: hidden;
}

#productList th,
#productList td {
  padding: 3px 5px;
  line-height: 1.25;
}

#productList td {
  white-space: nowrap;
}

#productList th:nth-child(1),
#productList td:nth-child(1) { width: 30px; }
#productList th:nth-child(2),
#productList td:nth-child(2) { width: 38px; }
#productList th:nth-child(3),
#productList td:nth-child(3) { width: 112px; }
#productList th:nth-child(4),
#productList td:nth-child(4) { width: 124px; }
#productList th:nth-child(5),
#productList td:nth-child(5) { width: auto; }
#productList th:nth-child(6),
#productList td:nth-child(6) { width: 54px; }
#productList th:nth-child(7),
#productList td:nth-child(7) { width: 52px; }
#productList th:nth-child(8),
#productList td:nth-child(8) { width: 74px; }
#productList th:nth-child(9),
#productList td:nth-child(9) { width: 72px; }
#productList th:nth-child(10),
#productList td:nth-child(10) { width: 106px; }
#productList th:nth-child(11),
#productList td:nth-child(11) { width: 74px; }
#productList th:nth-child(12),
#productList td:nth-child(12) { width: 74px; }
#productList th:nth-child(13),
#productList td:nth-child(13) { width: 76px; }

#productList td:nth-child(5) {
  min-width: 0;
  max-width: none;
}

#productList td:nth-child(5) strong,
#productList td:nth-child(5) .muted {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#productList .chip {
  max-width: 118px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#productList .tag-stack {
  flex-wrap: nowrap;
  max-width: 122px;
  overflow: hidden;
}

#productList .tag {
  flex: 0 0 auto;
}

#productList th:nth-last-child(3),
#productList td:nth-last-child(3) {
  position: static;
  right: auto;
  background: inherit;
  box-shadow: none;
}

#productList th:nth-last-child(2),
#productList td:nth-last-child(2) {
  position: static;
  right: auto;
  background: inherit;
}

#productList th:last-child,
#productList td:last-child {
  position: static;
  right: auto;
  width: 76px;
  background: inherit;
}

#productList th:nth-last-child(3),
#productList th:nth-last-child(2),
#productList th:last-child {
  z-index: 3;
  background: var(--surface-table-head);
}

#productList td:nth-last-child(3),
#productList td:nth-last-child(2),
#productList td:last-child {
  z-index: 2;
}

th,
td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-table-head);
  color: #344054;
  font-weight: 700;
  font-size: 12px;
}

td {
  height: 32px;
}

tbody tr:nth-child(even) {
  background: #fcfdfe;
}

tr.clickable:hover {
  background: #f2f8f8;
}

.mini-img {
  width: 30px;
  height: 30px;
  object-fit: cover;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.qty-input,
.target-input {
  width: 64px;
  padding: 5px 6px;
}

.product-list .secondary {
  min-height: 28px;
  padding: 5px 7px;
  white-space: nowrap;
}

#productList .qty-input,
#productList .target-input {
  min-height: 28px;
  padding: 4px 6px;
}

.product-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  padding: 10px;
}

.product-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 8px;
  min-height: 258px;
}

.product-card:hover {
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.product-card img {
  width: 100%;
  aspect-ratio: 1 / 0.72;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface-2);
}

.product-card h3 {
  min-height: 38px;
}

.price {
  font-weight: 800;
  color: var(--teal-dark);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.tag-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.tag.special {
  background: var(--rose-soft);
  color: var(--rose);
}

.stock-zero {
  color: var(--red);
  font-weight: 700;
}

.special-module {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid rgba(180, 35, 90, 0.28);
  background: #fffafb;
  box-shadow: var(--shadow-soft);
}

.special-grid,
.split-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(360px, 1fr));
  align-items: start;
}

.settings-grid > .pricing-rule-panel,
.settings-grid > .panel:has(.table-wrap) {
  grid-column: 1 / -1;
}

.video-grid {
  display: block;
}

.video-shelf {
  max-height: none;
  overflow: hidden;
  border-style: dashed;
}

.special-card {
  background: #fff;
  border: 1px solid rgba(180, 35, 90, 0.22);
  border-radius: var(--radius);
  padding: 10px;
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 10px;
}

.special-card img {
  width: 74px;
  height: 74px;
  object-fit: cover;
  border-radius: 6px;
}

.warning {
  color: var(--amber);
  background: var(--amber-soft);
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 6px;
}

.panel {
  padding: 10px;
  display: grid;
  gap: 9px;
}

.decision-panel {
  border-color: rgba(0, 107, 103, 0.24);
  background: linear-gradient(180deg, #ffffff 0, #f8fcfb 100%);
}

.decision-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.decision-head p {
  color: var(--muted);
  margin-top: 3px;
}

.decision-kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.decision-kpis span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid rgba(0, 107, 103, 0.16);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
}

.decision-kpis strong {
  color: var(--teal-dark);
  font-size: 16px;
}

.decision-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border: 1px solid rgba(0, 107, 103, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

.decision-table table {
  min-width: 1040px;
}

.empty-action {
  display: grid;
  gap: 6px;
  padding: 12px;
  color: var(--muted);
}

.empty-action strong {
  color: var(--ink);
}

.stack {
  display: grid;
  gap: 10px;
}

#salesTables,
#procurementTables {
  order: 1;
}

.sales-actions,
.procurement-actions {
  order: 2;
}

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

.inquiry-batch {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
}

.batch-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.batch-head h4 {
  margin: 0;
  font-size: 14px;
}

.batch-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  padding: 3px 8px;
  font-size: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 9px 10px;
  display: grid;
  gap: 3px;
}

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

.metric strong {
  color: var(--ink);
  font-size: 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  background: rgba(15, 118, 110, 0.08);
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.risk-pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: 999px;
  padding: 1px 7px;
  border: 1px solid rgba(15, 118, 110, 0.2);
  background: rgba(15, 118, 110, 0.08);
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.risk-pill.warn {
  border-color: rgba(164, 90, 8, 0.28);
  background: var(--amber-soft);
  color: var(--amber);
}

.risk-pill.danger {
  border-color: rgba(185, 28, 28, 0.24);
  background: rgba(254, 226, 226, 0.78);
  color: var(--red);
}

.risk-pill.ok {
  border-color: rgba(0, 107, 103, 0.22);
  background: var(--green-soft);
  color: var(--teal-dark);
}

.status-brand-approval-required,
.status-brand-pending {
  border-color: rgba(180, 83, 9, 0.28);
  background: var(--amber-soft);
  color: var(--amber);
}

.status-brand-rejected {
  border-color: rgba(185, 28, 28, 0.25);
  background: rgba(254, 226, 226, 0.75);
  color: #991b1b;
}

.status-sales-confirmed {
  border-color: rgba(22, 101, 52, 0.22);
  background: rgba(220, 252, 231, 0.7);
  color: #166534;
}

.pricing-summary-line {
  display: grid;
  gap: 2px;
  min-width: 180px;
}

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

.row-sep {
  border: 0;
  border-top: 1px dashed var(--line);
  margin: 5px 0;
}

.compact-input {
  min-height: 30px;
  padding: 5px 7px;
}

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

.inquiry-item-line {
  display: grid;
  gap: 2px;
}

.inquiry-item-line + .inquiry-item-line {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.inquiry-item-line span {
  color: var(--muted);
  font-size: 12px;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.panel > :is(.primary, .secondary, .ghost, .danger, .file-button),
.grid-form > :is(.primary, .secondary, .ghost, .danger, .file-button),
.setting-form > :is(.primary, .secondary, .ghost, .danger, .file-button) {
  width: fit-content;
  max-width: 100%;
  justify-self: start;
  align-self: start;
}

.grid-form > :is(.primary, .secondary, .ghost, .danger, .file-button) {
  align-self: end;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.compact-actions {
  justify-self: start;
}

.compact-actions .primary {
  min-width: 108px;
}

.compact-actions .message {
  margin: 0;
}

.video-carousel {
  --video-index: 0;
  --video-offset: 0%;
  display: grid;
  gap: 7px;
  overflow: hidden;
}

.video-track {
  display: flex;
  transform: translateX(var(--video-offset));
  transition: transform 520ms ease;
}

.video-slide {
  min-width: 100%;
}

.video-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.video-card:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.45);
  outline-offset: 2px;
}

.video-frame {
  position: relative;
  overflow: hidden;
  background: #101414;
}

.video-frame video {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #101414;
  pointer-events: none;
}

.video-badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  max-width: calc(100% - 20px);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--teal-dark);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}

.video-meta {
  padding: 8px 9px;
  display: grid;
  gap: 3px;
}

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

.video-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.video-dots span,
.video-dots button {
  width: 20px;
  height: 3px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--line);
  cursor: pointer;
  transition: background 0.18s ease, width 0.18s ease;
}

.video-dots span.is-active,
.video-dots button.is-active {
  width: 28px;
  background: var(--teal);
}

.video-dots button:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.35);
  outline-offset: 3px;
}

.video-carousel.login {
  height: 100%;
}

.video-carousel.login .video-track {
  height: 100%;
  min-height: 0;
  display: flex;
}

.video-carousel.login .video-slide {
  height: 100%;
  min-height: 0;
  min-width: 100%;
  overflow: hidden;
}

.video-carousel.login .video-dots {
  display: flex;
}

.video-carousel.login .video-card {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  border: 0;
  background: #f8fbfb;
}

.video-carousel.login .video-frame,
.video-carousel.login .video-frame video {
  background: #eef2f4;
}

.video-carousel.login .video-frame,
.video-carousel.login .video-frame video {
  height: 100%;
  min-height: 0;
}

.video-carousel.login .video-frame video {
  aspect-ratio: auto;
  object-fit: contain;
}

.video-carousel.home .video-card {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  align-items: stretch;
}

.video-carousel.home .video-frame video {
  height: 96px;
  aspect-ratio: auto;
}

.video-carousel.home .video-meta strong {
  line-height: 1.35;
}

.settings-grid .panel textarea {
  min-height: 118px;
  resize: vertical;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 12px;
  line-height: 1.45;
  background: #fbfcfd;
}

.setting-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.setting-summary div {
  display: grid;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

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

.setting-summary strong {
  color: var(--ink);
  font-weight: 700;
  line-height: 1.35;
}

.business-config {
  display: grid;
  gap: 10px;
}

.setting-fieldset {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fbfcfd;
  padding: 10px;
}

.setting-fieldset h4 {
  margin: 0;
  font-size: 14px;
}

.business-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
  align-items: start;
}

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

.field-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.check-grid .checkline {
  width: auto;
  min-height: 30px;
  align-items: center;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
}

.business-table table {
  min-width: 760px;
}

.business-table input,
.business-table select {
  min-width: 150px;
}

.raw-config {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.raw-config summary {
  cursor: pointer;
  color: var(--muted);
  padding: 8px 10px;
  list-style-position: inside;
}

.raw-config[open] {
  padding-bottom: 8px;
}

.raw-config textarea {
  width: calc(100% - 16px);
  margin: 0 8px;
}

.settings-grid > .setting-form[data-setting-key="auto_pricing_rules"] {
  grid-column: 1 / -1;
}

.settings-grid > .setting-form[data-setting-key="auto_pricing_rules"] textarea {
  min-height: 112px;
}

.pricing-rule-layout {
  display: grid;
  grid-template-columns: minmax(320px, 370px) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.rule-preview-card {
  display: grid;
  gap: 4px;
  border: 1px solid rgba(0, 107, 103, 0.18);
  border-radius: var(--radius);
  background: #f6fbfa;
  padding: 9px 10px;
}

.rule-preview-card strong {
  color: var(--teal-dark);
}

.rule-preview-card span {
  color: var(--muted);
  line-height: 1.5;
}

.rule-governance {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.rule-governance button {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 8px 10px;
  text-align: left;
}

.rule-governance button:hover {
  border-color: rgba(0, 107, 103, 0.28);
  background: #f8fcfb;
}

.rule-governance span {
  color: var(--muted);
}

.rule-governance strong {
  color: var(--ink);
  font-size: 16px;
}

.danger-text {
  color: var(--red) !important;
}

.rule-tester-card {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: var(--radius);
  background: #f7fbff;
  padding: 10px;
}

.rule-tester-card > div:first-child {
  display: grid;
  gap: 2px;
}

.rule-tester-card strong {
  color: var(--ink);
}

.rule-tester-card span {
  color: var(--muted);
}

.rule-tester-card .grid-form {
  grid-template-columns: minmax(240px, 1.2fr) 100px 120px 100px auto;
}

.rule-test-result {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 8px 10px;
}

.rule-test-result strong {
  color: var(--teal-dark);
}

.pricing-rule-panel .grid-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-self: start;
}

.pricing-rule-panel .wide {
  grid-column: 1 / -1;
}

.pricing-rule-table {
  min-height: 338px;
}

.pricing-rule-table table {
  min-width: 760px;
}

.product-dialog {
  width: min(1200px, calc(100vw - 24px));
  max-width: min(1200px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  margin: auto;
  box-shadow: var(--shadow);
}

.confirm-dialog {
  width: min(720px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  margin: auto;
  box-shadow: var(--shadow);
}

.confirm-dialog::backdrop {
  background: rgba(23, 32, 31, 0.42);
}

#inquiryConfirmContent {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.confirm-head {
  display: grid;
  gap: 4px;
}

.confirm-head p {
  color: var(--muted);
}

.confirm-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.confirm-metrics span,
.confirm-flow div {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 8px 10px;
}

.confirm-metrics .primary-metric {
  border-color: rgba(0, 107, 103, 0.24);
  background: #f3fbf9;
}

.confirm-metrics strong {
  color: var(--teal-dark);
  font-size: 18px;
  overflow-wrap: anywhere;
}

.danger-bg {
  border-color: rgba(185, 28, 28, 0.24) !important;
  background: rgba(254, 226, 226, 0.72) !important;
}

.confirm-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.confirm-flow span {
  color: var(--muted);
}

.confirm-table table {
  min-width: 0;
}

.confirm-table th,
.confirm-table td {
  padding: 5px 7px;
}

.confirm-actions {
  justify-content: flex-end;
}

.product-dialog::backdrop {
  background: rgba(23, 32, 31, 0.45);
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
}

.detail-layout img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.detail-info {
  display: grid;
  gap: 10px;
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 6px;
  padding: 5px 8px;
}

@media (max-width: 760px) {
  .product-dialog {
    width: calc(100vw - 8px);
    max-width: calc(100vw - 8px);
    max-height: calc(100vh - 8px);
  }

  .detail-layout {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .detail-layout img {
    max-width: 420px;
  }
}

.aiqa-button {
  position: fixed;
  left: auto;
  right: 18px;
  bottom: 18px;
  z-index: 35;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
  box-shadow: var(--shadow);
  opacity: 0.72;
  transform: scale(0.92);
  transition: opacity 160ms ease, transform 160ms ease;
}

.aiqa-button:hover {
  opacity: 1;
  transform: scale(1);
}

.soft-feedback {
  position: fixed;
  right: 70px;
  bottom: 24px;
  z-index: 36;
  min-height: 34px;
  max-width: min(280px, calc(100vw - 104px));
  display: flex;
  align-items: center;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--teal-dark);
  box-shadow: 0 10px 24px rgba(23, 32, 31, 0.1);
  padding: 7px 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.soft-feedback.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.aiqa-panel {
  position: fixed;
  right: 18px;
  bottom: 72px;
  z-index: 34;
  width: min(380px, calc(100vw - 28px));
  max-height: min(620px, calc(100vh - 100px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto minmax(180px, 1fr) auto;
  overflow: hidden;
}

.aiqa-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
}

.aiqa-messages {
  padding: 10px;
  display: grid;
  gap: 8px;
  overflow: auto;
}

.aiqa-msg {
  padding: 8px;
  border-radius: 7px;
  background: var(--surface-2);
}

.aiqa-msg.user {
  background: var(--green-soft);
}

.aiqa-form {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
}

@keyframes addButtonPulse {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.035);
  }
  100% {
    transform: scale(1);
  }
}

@media (max-width: 860px) {
  #client {
    grid-template-columns: 1fr;
  }

  #client > .section-head,
  #client > .toolbar,
  #client > #clientBasket,
  #client > .chip-row,
  #client > .bulk-bar,
  #client > .product-list,
  #client > #client-inquiry {
    grid-column: 1;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .business-grid {
    grid-template-columns: 1fr;
  }

  .pricing-rule-layout {
    grid-template-columns: 1fr;
  }

  .decision-tools {
    align-items: flex-start;
    flex-direction: column;
  }

  .rule-tester-card .grid-form {
    grid-template-columns: 1fr 1fr;
  }

  .rule-governance {
    grid-template-columns: 1fr 1fr;
  }

  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-copy {
    min-height: auto;
  }

  .login-video-grid {
    min-height: 260px;
  }

  .toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .basket-summary {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .basket-metrics {
    justify-content: flex-start;
  }

  .basket-state {
    justify-self: start;
  }

  .section-head,
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .confirm-metrics,
  .confirm-flow {
    grid-template-columns: 1fr 1fr;
  }

  .detail-layout img {
    width: 100%;
    max-height: 300px;
  }
}

@media (max-width: 560px) {
  main,
  .topbar,
  .main-nav {
    padding-left: 8px;
    padding-right: 8px;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .workflow-strip {
    grid-template-columns: 1fr 1fr;
  }

  .pricing-rule-panel .grid-form {
    grid-template-columns: 1fr;
  }

  .rule-tester-card .grid-form {
    grid-template-columns: 1fr;
  }

  .rule-governance {
    grid-template-columns: 1fr;
  }

  .head-actions,
  .bulk-bar {
    flex-wrap: wrap;
  }

  .confirm-metrics,
  .confirm-flow {
    grid-template-columns: 1fr;
  }

  .soft-feedback {
    right: 70px;
    bottom: 22px;
  }
}
