.resource-workspace {
  width: 100%;
  min-height: 100vh;
  grid-template-columns: minmax(0, 1fr);
  overflow-x: hidden;
}

.resource-workspace .workspace-header {
  min-width: 0;
  min-height: 76px;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: clamp(12px, 1.5vw, 24px);
}

.resource-workspace .workspace-header h1 { white-space: nowrap; }

.resource-workspace .top-nav {
  width: 100%;
  justify-self: stretch;
}

.resource-workspace .language-button {
  flex: 0 0 auto;
  border-color: #146c43;
  color: #0f5b3a;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 91, 58, 0.12);
  white-space: nowrap;
}

.resource-workspace .language-button:hover {
  color: #ffffff;
  background: #146c43;
}

.language-switch {
  flex: 0 0 auto;
  display: inline-grid;
  grid-template-columns: repeat(2, max-content);
  align-items: stretch;
  justify-self: end;
  overflow: hidden;
  border: 1px solid #8ab7a0;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 91, 58, 0.12);
}

.language-option {
  min-width: 66px;
  min-height: 38px;
  padding: 0 13px;
  border: 0;
  border-right: 1px solid #c8ddd1;
  color: #23543d;
  background: #ffffff;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

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

.language-option:hover { background: #eef7f1; }

.language-option.active {
  color: #ffffff;
  background: #146c43;
}

.language-option:focus-visible {
  position: relative;
  z-index: 1;
  outline: 3px solid rgba(20, 108, 67, 0.28);
  outline-offset: -3px;
}

.resource-content {
  width: 100%;
  min-width: 0;
  padding: 24px clamp(18px, 3vw, 48px) 36px;
}

.selection-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid #c9d9d0;
  border-radius: 7px;
  background: #ffffff;
  box-shadow: 0 5px 18px rgba(22, 73, 49, 0.05);
}

.summary-metric {
  min-width: 0;
  padding: 12px 16px;
  border-right: 1px solid #dce6e0;
}

.summary-metric:last-child { border-right: 0; }
.summary-metric span {
  display: block;
  margin-bottom: 3px;
  color: #6a7871;
  font-size: 10px;
  font-weight: 600;
}

.summary-metric strong {
  display: block;
  color: #17382b;
  font-size: 16px;
  line-height: 1.25;
  white-space: nowrap;
}

.summary-total { background: #edf8f2; }
.summary-total strong { color: #0f6840; }

.resource-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
  padding: 16px 18px;
  border: 1px solid #d3ddd7;
  border-radius: 7px;
  background: #ffffff;
}

.resource-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: max-content minmax(260px, 1fr);
  align-items: center;
  gap: 8px 24px;
}

.resource-meta strong { color: #17382b; font-size: 12px; }
.resource-meta span { color: #6a7871; font-size: 11px; }
.resource-meta .resource-stock-note {
  color: #30483a;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
}

.export-meta {
  grid-template-columns: max-content minmax(320px, 1fr);
}

.export-meta strong {
  font-size: 12px;
  line-height: 1.55;
}

.export-meta .resource-stock-note {
  grid-column: 1 / -1;
}

.resource-actions {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.search-box { margin: 0; }
.search-box span { display: block; margin-bottom: 5px; font-size: 11px; }

.search-box input {
  width: min(300px, 38vw);
  height: 40px;
  padding: 0 12px;
  border: 1px solid #bcc9c2;
  border-radius: 6px;
  outline: none;
  font: inherit;
}

.search-box input:focus {
  border-color: #146c43;
  box-shadow: 0 0 0 3px rgba(20, 108, 67, 0.1);
}

.excel-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid #146c43;
  border-radius: 6px;
  color: #ffffff;
  background: #146c43;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.excel-button:hover:not(:disabled) { background: #0f5937; }
.excel-button:disabled {
  border-color: #c8d3cd;
  color: #7c8982;
  background: #e8edeb;
  cursor: not-allowed;
}

.resource-table-panel {
  position: relative;
  min-width: 0;
  border: 1px solid #d3ddd7;
  border-radius: 7px;
  overflow: hidden;
  background: #ffffff;
}

.table-scroll {
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: calc(100vh - 290px);
}

table {
  min-width: 0;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  color: #26372f;
  font-size: 9px;
}

th,
td {
  padding: 3px 8px;
  border-right: 1px solid #e0e6e2;
  border-bottom: 1px solid #e0e6e2;
  text-align: left;
  vertical-align: middle;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: #17382b;
  background: #eaf1ed;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.sort-button {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  font-weight: inherit;
  text-align: left;
}

.sort-button:focus-visible {
  outline: 2px solid #146c43;
  outline-offset: 3px;
}

.sort-indicator { color: #6f8277; font-size: 10px; line-height: 1; }
th[aria-sort="ascending"] .sort-indicator,
th[aria-sort="descending"] .sort-indicator { color: #146c43; }

th:last-child,
td:last-child { border-right: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f6f9f7; }
tbody tr.is-selected td { background: #e7f5ec; }
tbody tr.is-selected:hover td { background: #dff0e6; }

.english-resources #resourceBody tr { cursor: crosshair; }
.english-resources #resourceBody button,
.english-resources #resourceBody input { cursor: pointer; }

.row-selection-marquee {
  position: fixed;
  z-index: 9999;
  display: none;
  pointer-events: none;
  border: 1px solid rgba(18, 126, 77, 0.86);
  border-radius: 3px;
  background: rgba(35, 167, 104, 0.16);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.42) inset;
}

.row-selection-marquee.is-active { display: block; }

th.selection-cell,
td.selection-cell {
  position: sticky;
  left: 0;
  padding: 0;
  background: #ffffff;
  text-align: center;
  vertical-align: middle;
}

th.selection-cell {
  z-index: 4;
  background: #eaf1ed;
}

td.selection-cell { z-index: 1; }
tbody tr:hover td.selection-cell { background: #f6f9f7; }
tbody tr.is-selected td.selection-cell { background: #e7f5ec; }
tbody tr.is-selected:hover td.selection-cell { background: #dff0e6; }

.selector-hit-area {
  min-height: 22px;
  display: grid;
  place-items: center;
  line-height: 0;
  cursor: pointer;
}

tbody .selector-hit-area {
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
}

tbody td.selection-cell .selector-hit-area {
  position: absolute;
  inset: 0;
  min-height: 0;
}

.table-scroll.drag-selecting,
.table-scroll.drag-selecting * {
  cursor: crosshair !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

.stock-selector {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: #16734a;
  cursor: pointer;
}

.stock-selector:focus-visible {
  outline: 3px solid rgba(22, 115, 74, 0.22);
  outline-offset: 2px;
}

.stock-selector:disabled { cursor: not-allowed; opacity: 0.45; }

th[data-column="序号"], td[data-column="序号"],
th[data-column="吨位"], td[data-column="吨位"],
th[data-column="价格"], td[data-column="价格"],
th[data-column="Weight (MT)"], td[data-column="Weight (MT)"],
th[data-column="CFR USD/MT"], td[data-column="CFR USD/MT"] {
  white-space: nowrap;
}

th[data-column="颜色"], td[data-column="颜色"] {
  max-width: 180px;
}

th[data-column="仓库"],
td[data-column="仓库"] {
  padding-right: 4px;
  padding-left: 4px;
  font-size: 8px;
  line-height: 1.2;
  white-space: nowrap;
}

th[data-column="质保书"],
td[data-column="质保书"],
th[data-column="MTC"],
td[data-column="MTC"] {
  padding-right: 6px;
  padding-left: 6px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

.english-resources .resource-content {
  padding-right: clamp(12px, 2vw, 32px);
  padding-left: clamp(12px, 2vw, 32px);
}

.english-resources th,
.english-resources td {
  padding-right: 8px;
  padding-left: 8px;
}

.english-resources th.selection-cell,
.english-resources td.selection-cell {
  padding: 0;
  line-height: 0;
}

.english-resources td[data-column="CFR USD/MT"] {
  color: #0f6840;
  font-weight: 700;
}

.certificate-button {
  width: 58px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid #16734a;
  border-radius: 5px;
  color: #ffffff;
  background: #16734a;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  white-space: nowrap;
}

.certificate-button:hover:not(:disabled) { background: #105d3b; }
.certificate-button:focus-visible { outline: 3px solid rgba(22, 115, 74, 0.22); outline-offset: 2px; }
.certificate-button:disabled { cursor: default; opacity: 1; }
.certificate-button[data-state="loading"] { color: #2f5e49; background: #e5f0ea; border-color: #b8cfc2; }
.certificate-button[data-state="success"] { background: #0f6840; border-color: #0f6840; }
.certificate-button[data-state="missing"] { color: #6b7771; background: #eef1ef; border-color: #d1d8d4; }
.certificate-button[data-state="error"] { color: #8b3a35; background: #fff0ee; border-color: #e8b9b4; }

.resource-empty { padding: 44px 20px; color: #78857e; text-align: center; }

@media (max-width: 760px) {
  .resource-workspace { grid-template-rows: auto 1fr; }
  .resource-workspace .workspace-header {
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    padding-top: 14px;
    padding-bottom: 12px;
  }
  .resource-workspace .workspace-header h1 { grid-column: 1; grid-row: 1; }
  .resource-workspace .top-nav { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .language-switch { grid-column: 2; grid-row: 1; }
  .resource-workspace .language-button { align-self: flex-start; }
  .resource-content { padding: 16px 12px 24px; }
  .selection-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-metric:nth-child(2) { border-right: 0; }
  .summary-metric:nth-child(-n+2) { border-bottom: 1px solid #dce6e0; }
  .resource-toolbar { align-items: stretch; flex-direction: column; }
  .resource-meta { grid-template-columns: 1fr; }
  .export-meta .resource-stock-note { grid-column: auto; }
  .resource-actions { align-items: stretch; flex-direction: column; }
  .search-box input { width: 100%; }
  .excel-button { width: 100%; }
  .table-scroll { overflow-x: auto; max-height: calc(100vh - 430px); }
}
