:root {
  --bg: #f5f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #697684;
  --line: #dce3e9;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #d97706;
  --danger: #b42318;
  --soft: #edf7f5;
  --shadow: 0 14px 40px rgba(32, 45, 58, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #10202b;
  color: #f7fbfd;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #0f766e, #d97706);
  font-size: 24px;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #aebbc5;
  font-size: 12px;
  margin-top: 3px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  padding: 12px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #d9e3e9;
  background: transparent;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 700;
}

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-note span,
.sidebar-note strong {
  display: block;
}

.sidebar-note span {
  color: #aebbc5;
  font-size: 12px;
}

.sidebar-note strong {
  margin-top: 4px;
  font-size: 14px;
}

.workspace {
  padding: 28px;
  overflow-x: hidden;
}

.topbar,
.panel-heading,
.detail-header,
.quote-actions,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

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

.topbar {
  margin-bottom: 22px;
}

.topbar h1,
.panel h2,
.detail-header h2 {
  margin: 0;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

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

.user-pill {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.primary-button,
.ghost-button,
.danger-button,
.text-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  min-height: 38px;
  padding: 0 14px;
  font-weight: 700;
}

.primary-button {
  color: #fff;
  background: var(--primary);
}

.primary-button:hover {
  background: var(--primary-dark);
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.danger-button {
  background: #fff1f0;
  color: var(--danger);
}

.danger-button.subtle {
  background: transparent;
}

.text-button {
  background: transparent;
  color: var(--primary);
  padding: 0;
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 22px;
  background: #eef3f5;
}

.small {
  min-height: 34px;
  padding: 0 12px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

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

.metric {
  padding: 18px;
}

.metric span,
.panel-heading p,
.detail-header span,
.quote-card p {
  color: var(--muted);
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-heading {
  margin-bottom: 14px;
}

.panel-heading h2 {
  font-size: 18px;
}

.panel-heading p {
  margin: 4px 0 0;
  font-size: 13px;
}

.split-layout,
.pricing-layout {
  display: grid;
  gap: 18px;
}

.split-layout {
  grid-template-columns: 390px minmax(0, 1fr);
}

.pricing-layout {
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
  align-items: start;
  min-width: 0;
}

.customer-panel,
.detail-panel {
  min-height: calc(100vh - 132px);
  min-width: 0;
}

.sticky-heading {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  padding-bottom: 12px;
}

.customer-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.customer-search label {
  font-size: 12px;
}

.customer-search input {
  min-height: 46px;
  font-size: 15px;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 11px;
}

input:focus,
select:focus {
  outline: 2px solid rgba(15, 118, 110, 0.18);
  border-color: var(--primary);
}

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

.customer-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  background: #fff;
  display: grid;
  gap: 8px;
}

.customer-card.active,
.customer-card:hover {
  border-color: rgba(15, 118, 110, 0.45);
  background: var(--soft);
}

.customer-card button {
  all: unset;
  cursor: pointer;
}

.customer-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.customer-main strong {
  overflow-wrap: anywhere;
}

.tag {
  height: 24px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
  background: #eaf0f2;
  color: #344450;
  white-space: nowrap;
}

.tag.alibaba {
  background: #fff4e4;
  color: #92400e;
}

.tag.x1688 {
  background: #e8f7f3;
  color: #0f766e;
}

.customer-meta {
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  min-height: 500px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  text-align: center;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.empty-visual {
  width: 124px;
  height: 88px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #e8f7f3, #fff4e4);
  color: var(--primary-dark);
  font-weight: 900;
  font-size: 30px;
}

.hidden {
  display: none !important;
}

.detail-content {
  display: grid;
  gap: 18px;
}

.detail-header {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.form-grid,
.pricing-form,
.dialog-form {
  display: grid;
  gap: 12px;
}

.form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

label input,
label select {
  margin-top: 6px;
}

.form-actions {
  grid-column: 1 / -1;
  justify-content: flex-end;
}

.section-line {
  border-top: 1px solid var(--line);
}

.customer-workbench {
  display: grid;
  gap: 14px;
}

.workbench-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.workbench-tab {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

.workbench-tab.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.workbench-pane {
  display: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: #fff;
}

.workbench-pane.active {
  display: grid;
  gap: 14px;
}

.embedded-pricing {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.embedded-pricing .panel-heading {
  margin-bottom: 0;
  align-items: flex-start;
  flex-wrap: wrap;
}

.quote-inputs {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fbfcfd;
  min-width: 0;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
}

td {
  font-size: 14px;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.row-actions button {
  min-height: 30px;
  padding: 0 10px;
}

.formula-badge {
  border-radius: 999px;
  background: #eef3f5;
  padding: 7px 11px;
  color: #344450;
  font-size: 13px;
  font-weight: 700;
  max-width: 100%;
  white-space: normal;
}

.pricing-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.order-lines-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.order-lines-head h3 {
  margin: 0;
  font-size: 16px;
}

.order-lines {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}

.order-line {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(150px, 1fr) minmax(116px, 0.7fr) auto;
  gap: 12px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fff;
}

.line-product {
  grid-column: 1 / -1;
}

.line-product select {
  min-height: 48px;
}

.line-quantity input,
.line-cost input {
  min-height: 46px;
}

.line-subtotal {
  min-height: 46px;
  display: grid;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: #f7fafb;
}

.line-subtotal span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.line-subtotal strong {
  font-size: 15px;
}

.remove-line-button {
  min-width: 64px;
  min-height: 46px;
}

.quote-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fff;
  min-width: 0;
}

.quote-card {
  border-radius: var(--radius);
  padding: 22px;
  background: #10202b;
  color: #fff;
}

.quote-card span {
  color: #9fd6cf;
  font-weight: 800;
}

.quote-card strong {
  display: block;
  margin: 10px 0;
  font-size: 38px;
  overflow-wrap: anywhere;
}

.quote-card p {
  margin: 0;
  color: #d9e3e9;
  overflow-wrap: anywhere;
}

.breakdown {
  display: grid;
  gap: 9px;
  margin: 16px 0;
}

.breakdown-row,
.quote-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
}

.breakdown-row span,
.quote-item span {
  color: var(--muted);
}

.saved-quotes {
  margin-top: 18px;
}

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

.quote-archive-panel {
  min-height: calc(100vh - 132px);
}

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

.quote-archive-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fff;
  cursor: pointer;
}

.quote-archive-item:hover {
  border-color: rgba(15, 118, 110, 0.45);
  background: var(--soft);
}

.quote-archive-total {
  display: grid;
  justify-items: end;
  gap: 4px;
  white-space: nowrap;
}

.quote-archive-total strong {
  font-size: 18px;
}

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

.history-form {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfd;
}

.history-form-grid,
.contract-builder {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

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

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
}

.history-amount {
  font-weight: 900;
  white-space: nowrap;
}

.product-library-layout {
  align-items: start;
}

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

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

.library-product-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fff;
}

.library-product-price {
  display: grid;
  justify-items: end;
  gap: 8px;
  white-space: nowrap;
}

.price-up {
  color: var(--danger);
  font-weight: 700;
}

.price-down {
  color: var(--primary);
  font-weight: 700;
}

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

.contract-preview {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fbfcfd;
}

.contract-paper {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: grid;
  gap: 8px;
}

.contract-paper h3,
.contract-paper p {
  margin: 0;
}

.contract-paper table {
  min-width: 0;
  margin-top: 8px;
}

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

.recognition-dialog textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  resize: vertical;
  font: inherit;
}

.image-preview {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7fafb;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #10202b;
}

.login-shell {
  width: min(440px, calc(100vw - 32px));
}

.login-card {
  display: grid;
  gap: 18px;
  border-radius: var(--radius);
  background: #fff;
  padding: 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.login-brand {
  padding: 0;
  color: var(--text);
}

.login-brand span {
  color: var(--muted);
}

.login-card h1 {
  margin: 0;
}

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

.login-form button {
  min-height: 44px;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-weight: 800;
}

.mini-pricing {
  display: grid;
  gap: 12px;
}

dialog {
  width: min(520px, calc(100vw - 28px));
  border: 0;
  border-radius: var(--radius);
  box-shadow: 0 22px 70px rgba(23, 32, 42, 0.28);
  padding: 0;
}

dialog::backdrop {
  background: rgba(16, 32, 43, 0.45);
}

.dialog-form {
  padding: 18px;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0;
  margin: 8px 0 0;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .brand div:not(.brand-mark),
  .nav-item span:last-child,
  .sidebar-note {
    display: none;
  }

  .nav-item {
    justify-content: center;
  }

  .metrics-grid,
  .content-grid,
  .split-layout,
  .pricing-layout {
    grid-template-columns: 1fr;
  }

  .customer-panel,
  .detail-panel {
    min-height: auto;
  }

  .quote-panel {
    position: static;
  }
}

@media (max-width: 1500px) {
  .pricing-layout {
    grid-template-columns: 1fr;
  }

  .quote-card strong {
    font-size: 34px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    flex-direction: row;
    align-items: center;
    padding: 10px;
  }

  .brand {
    padding: 0;
  }

  .nav {
    grid-auto-flow: column;
    margin-left: auto;
  }

  .workspace {
    padding: 16px;
  }

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

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions button {
    flex: 1;
  }

  .metrics-grid,
  .form-grid,
  .pricing-form,
  .product-library-form,
  .history-form-grid,
  .contract-builder,
  .customer-search {
    grid-template-columns: 1fr;
  }

  .order-line {
    grid-template-columns: 1fr;
  }

  .quote-archive-item {
    grid-template-columns: 1fr;
  }

  .quote-archive-total {
    justify-items: start;
    white-space: normal;
  }

  .library-product-card {
    grid-template-columns: 1fr;
  }

  .library-product-price {
    justify-items: start;
    white-space: normal;
  }

  .history-item {
    grid-template-columns: 1fr;
  }

  .quote-card strong {
    font-size: 30px;
  }
}
