:root {
  --bg: #eef2f6;
  --panel: #ffffff;
  --panel-soft: #f7f9fb;
  --ink: #15202b;
  --muted: #657282;
  --line: #d9e1ea;
  --brand: #1f6f78;
  --brand-dark: #15575f;
  --accent: #b95b26;
  --success: #23784f;
  --warning: #a96c13;
  --danger: #b44747;
  --shadow: 0 18px 45px rgba(31, 47, 70, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(31, 111, 120, 0.14), transparent 36%),
    var(--bg);
}

.login-screen[hidden] {
  display: none;
}

.login-card {
  display: grid;
  width: min(380px, 100%);
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 4px;
  color: var(--ink);
}

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

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-card input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #ffffff;
}

.login-error {
  margin: 0;
  border: 1px solid rgba(180, 71, 71, 0.24);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--danger);
  background: rgba(180, 71, 71, 0.08);
  font-size: 13px;
}

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

.app-shell[hidden] {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  padding: 24px 18px;
  color: #ecf4f5;
  background: #173d43;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  background: #e8f3f1;
  color: #173d43;
  font-weight: 800;
}

.brand-kicker {
  margin: 0 0 2px;
  color: rgba(236, 244, 245, 0.7);
  font-size: 12px;
  text-transform: uppercase;
}

.brand h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 750;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  color: rgba(236, 244, 245, 0.74);
  background: transparent;
  text-align: left;
}

.nav-item.active {
  color: #173d43;
  background: #e8f3f1;
  font-weight: 700;
}

.nav-item:disabled {
  opacity: 0.55;
}

.nav-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  font-weight: 800;
}

.sidebar-note {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 12px;
  color: rgba(236, 244, 245, 0.76);
  background: rgba(255, 255, 255, 0.06);
  font-size: 13px;
  line-height: 1.6;
}

.sidebar-note p {
  margin: 0;
}

.sidebar-logout {
  width: 100%;
  min-height: 34px;
  margin-top: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #ecf4f5;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 700;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 24px;
}

.app-view {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 18px;
}

.app-view[hidden] {
  display: none;
}

.topbar,
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
}

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

.topbar h2 {
  font-size: 28px;
  line-height: 1.2;
}

.panel-header h3 {
  font-size: 18px;
}

.panel-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.primary-button,
.secondary-button,
.small-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  font-weight: 750;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 16px;
  color: #ffffff;
  background: var(--brand);
  box-shadow: 0 10px 20px rgba(31, 111, 120, 0.2);
}

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

.secondary-button,
.small-button {
  color: var(--brand);
  background: #e4eff0;
}

.secondary-button {
  min-height: 40px;
  padding: 0 16px;
}

.small-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

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

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

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

.metric-card {
  display: grid;
  gap: 8px;
  padding: 18px;
}

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

.metric-card strong {
  font-size: 28px;
}

.workspace {
  min-width: 0;
}

.panel {
  min-width: 0;
}

.table-panel {
  overflow: hidden;
}

.panel-header {
  justify-content: flex-end;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
}

.panel-header .search-box {
  margin-right: auto;
}

.search-box,
.select-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 13px;
}

.search-box input,
.select-box select {
  width: 180px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.select-box select {
  width: 118px;
}

.table-wrap {
  max-height: calc(100vh - 292px);
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #f4f7fa;
  font-size: 11px;
  font-weight: 800;
}

tbody tr:hover {
  background: #fbfcfd;
}

.summary-row.is-expanded {
  background: #f7fafb;
}

.site-name {
  display: grid;
  gap: 5px;
  max-width: 150px;
  font-weight: 750;
  line-height: 1.45;
}

.copyable-value {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  border: 0;
  padding: 0;
  color: #344252;
  background: transparent;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  text-align: left;
}

.copyable-value span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copyable-value i {
  flex: 0 0 auto;
  color: #83909d;
  font-size: 12px;
  font-style: normal;
}

.copyable-value:hover {
  color: var(--brand);
}

.copyable-value:hover i,
.copyable-value[data-copied="true"] i {
  color: var(--brand);
}

.copyable-value[data-copied="true"]::after {
  content: "已复制";
  flex: 0 0 auto;
  color: var(--success);
  font-size: 11px;
  font-weight: 700;
}

.address-copy {
  max-width: 90px;
  overflow: hidden;
  color: var(--brand);
  font-size: 12px;
}

.last-win-copy {
  max-width: 150px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

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

.status,
.type-badge {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  border-radius: 6px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.status.approved {
  color: var(--success);
  background: #def1e7;
}

.status.pending {
  color: var(--warning);
  background: #fff0d8;
}

.status.rejected {
  color: var(--danger);
  background: #f8e0e0;
}

.status.other {
  color: #5d6470;
  background: #e9edf2;
}

.type-badge.bidding {
  color: #17616a;
  background: #dfeff0;
}

.type-badge.tool {
  color: #81501e;
  background: #f7eadb;
}

.classification-cell {
  display: grid;
  gap: 4px;
  min-width: 96px;
  line-height: 1.35;
}

.classification-cell strong {
  font-size: 12px;
}

.classification-cell .muted {
  font-size: 11px;
}

.tag-list {
  display: flex;
  max-width: 160px;
  flex-wrap: wrap;
  gap: 5px;
}

.function-tag {
  display: inline-flex;
  min-height: 20px;
  align-items: center;
  border: 1px solid #d6dee8;
  border-radius: 5px;
  padding: 0 6px;
  color: #4c5b6b;
  background: #f5f7fa;
  font-size: 11px;
  white-space: nowrap;
}

.win-cell {
  display: grid;
  gap: 2px;
}

.win-cell strong {
  color: var(--accent);
}

.row-actions {
  display: flex;
  gap: 5px;
  white-space: nowrap;
}

.row-actions .small-button {
  min-height: 26px;
  padding: 0 8px;
  font-size: 12px;
}

.toggle-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.detail-row[hidden] {
  display: none;
}

.detail-row td {
  padding: 0;
  background: #f7fafb;
}

.detail-row:hover {
  background: #f7fafb;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(160px, 1fr) minmax(140px, 1fr) minmax(260px, 2fr);
  border-top: 1px solid #e4eaf0;
  box-shadow: inset 3px 0 0 var(--brand);
}

.detail-item {
  min-width: 0;
  border-right: 1px solid #e1e7ed;
  padding: 11px 14px;
}

.detail-item:last-child {
  border-right: 0;
}

.detail-item > span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.detail-item strong,
.detail-item p {
  margin: 0;
  color: #344252;
  font-size: 12px;
  line-height: 1.5;
}

.detail-item strong {
  font-weight: 750;
}

.detail-item .copyable-value {
  max-width: 100%;
  color: #344252;
  font-size: 12px;
  font-weight: 750;
}

.detail-notes .copyable-value {
  font-weight: 500;
}

.password-value {
  overflow-wrap: anywhere;
}

body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 29, 39, 0.58);
  backdrop-filter: blur(3px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(840px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(15, 31, 43, 0.28);
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 18px 20px;
  background: #ffffff;
}

.modal-header h3 {
  margin: 0;
  font-size: 20px;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  color: #4d5966;
  background: #edf1f5;
  font-size: 24px;
  line-height: 1;
}

form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

label {
  display: grid;
  gap: 7px;
  color: #344252;
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  background: #ffffff;
  outline: 0;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 111, 120, 0.14);
}

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

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  margin: 2px -20px -20px;
  padding: 16px 20px;
  background: #f8fafb;
}

.empty-state {
  padding: 34px 18px;
  color: var(--muted);
  text-align: center;
}

.quote-topbar {
  align-items: flex-end;
}

.workflow-steps {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.workflow-steps span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.workflow-steps b,
.step-number {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--brand);
  font-size: 11px;
}

.quote-layout {
  display: grid;
  min-width: 0;
  align-items: start;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
}

.quote-controls {
  display: grid;
  gap: 14px;
}

.quote-workspace {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 14px;
}

.quote-workspace[hidden] {
  display: none;
}

.quote-section {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.quote-section-header {
  display: flex;
  min-height: 50px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 11px 14px;
}

.quote-section-header > div {
  display: flex;
  align-items: center;
  gap: 9px;
}

.quote-section-header h3 {
  margin: 0;
  font-size: 15px;
}

.result-count {
  color: var(--muted);
  font-size: 12px;
}

.product-family-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
}

.product-family-option {
  display: grid;
  min-height: 104px;
  align-content: center;
  gap: 6px;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 14px 16px;
  color: var(--ink);
  background: #ffffff;
  text-align: left;
}

.product-family-option:last-child {
  border-right: 0;
}

.product-family-option:hover:not(:disabled) {
  background: #f4f8f8;
}

.product-family-option.is-active {
  color: var(--brand-dark);
  background: #e7f1f1;
  box-shadow: inset 0 -3px 0 var(--brand);
}

.product-family-option:disabled {
  cursor: not-allowed;
  color: #8a95a1;
  background: #f7f9fb;
}

.product-family-option strong {
  font-size: 14px;
}

.product-family-option span,
.product-family-option small {
  font-size: 11px;
  line-height: 1.4;
}

.product-family-option span {
  color: var(--muted);
}

.product-family-option small {
  color: var(--brand);
  font-weight: 750;
}

.product-family-option:disabled small {
  color: #929ca6;
}

.product-filters {
  display: grid;
  grid-template-columns: minmax(170px, 1.5fr) repeat(6, minmax(92px, 1fr));
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  background: #f8fafb;
}

.dynamic-filter-fields {
  display: contents;
}

.product-filters label,
.compact-form label {
  gap: 5px;
  font-size: 11px;
}

.product-filters input,
.product-filters select,
.compact-form input,
.compact-form select {
  min-height: 34px;
  padding: 7px 9px;
  font-size: 12px;
}

.product-table-wrap {
  max-height: 492px;
  overflow: auto;
}

.product-table {
  min-width: 820px;
}

.product-table th,
.product-table td {
  padding: 8px 9px;
}

.product-table td {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-table tbody tr {
  cursor: pointer;
}

.product-table tbody tr.is-selected {
  background: #eaf3f3;
  box-shadow: inset 3px 0 0 var(--brand);
}

.product-table .select-product-button {
  min-height: 25px;
  padding: 0 8px;
  font-size: 11px;
}

.catalog-price {
  color: var(--accent);
  font-weight: 800;
  white-space: nowrap;
}

.selected-product {
  min-height: 104px;
  padding: 14px;
  background: #f8fafb;
}

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

.selected-product-content {
  display: grid;
  gap: 8px;
}

.selected-product-content strong {
  font-size: 16px;
}

.selected-product-content span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.selected-product-content .selected-price {
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
}

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

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

.logistics-form {
  padding-bottom: 10px;
}

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

.quote-generate-button {
  width: calc(100% - 28px);
  margin: 0 14px 14px;
}

.quote-output-section {
  box-shadow: none;
}

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

.generated-block {
  min-height: 82px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
}

.generated-block:nth-child(3n) {
  border-right: 0;
}

.generated-block:nth-last-child(-n + 3) {
  border-bottom: 0;
}

.generated-block span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.generated-block p {
  margin: 0;
  color: #273746;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.6;
  white-space: pre-wrap;
}

.quote-placeholder {
  grid-column: 1 / -1;
  padding: 34px;
  color: var(--muted);
  text-align: center;
}

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

  .quote-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

  .product-family-option:nth-child(3) {
    border-right: 0;
  }

  .product-family-option:nth-child(n + 4) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    gap: 16px;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar-note {
    display: none;
  }

  .main {
    padding: 18px;
  }

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

  .topbar,
  .panel-header,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .workflow-steps {
    width: 100%;
    overflow-x: auto;
  }

  .quote-controls,
  .quote-blocks {
    grid-template-columns: 1fr;
  }

  .product-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-family-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-family-option,
  .product-family-option:nth-child(3) {
    border-right: 1px solid var(--line);
  }

  .product-family-option:nth-child(even) {
    border-right: 0;
  }

  .product-family-option:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .generated-block,
  .generated-block:nth-child(3n),
  .generated-block:nth-last-child(-n + 3) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .generated-block:last-child {
    border-bottom: 0;
  }

  .search-box input,
  .select-box select {
    width: 100%;
  }

  .panel-header .search-box {
    margin-right: 0;
  }

  .table-wrap {
    max-height: none;
  }

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

  .detail-item:nth-child(2) {
    border-right: 0;
  }
}

@media (max-width: 560px) {
  .metrics,
  .form-grid,
  .classification-grid,
  .nav-list {
    grid-template-columns: 1fr;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 92vh;
    border-radius: 8px 8px 0 0;
  }

  .modal-actions {
    position: sticky;
    bottom: 0;
  }

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

  .detail-item {
    border-right: 0;
    border-bottom: 1px solid #e1e7ed;
  }

  .detail-item:last-child {
    border-bottom: 0;
  }

  .product-filters,
  .compact-form {
    grid-template-columns: 1fr;
  }

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

  .product-family-option,
  .product-family-option:nth-child(3),
  .product-family-option:nth-child(even) {
    min-height: 82px;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .product-family-option:first-child {
    border-top: 0;
  }

  .full-field {
    grid-column: auto;
  }
}
