:root {
  --ink: #17191c;
  --muted: #687078;
  --line: #dce1e5;
  --soft: #f4f6f7;
  --paper: #ffffff;
  --accent: #006b63;
  --accent-dark: #004d48;
  --success: #227447;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --warning: #985d00;
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button, input { font: inherit; letter-spacing: 0; }

.shell {
  width: calc(100% - 176px);
  margin: 0 auto;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
}

.search-band {
  display: grid;
  grid-template-columns: minmax(380px, 0.8fr) minmax(600px, 1.2fr);
  align-items: end;
  column-gap: 56px;
  padding: 50px 0 38px;
  border-bottom: 1px solid var(--line);
}

.search-heading { margin-bottom: 0; }
.eyebrow { color: var(--accent); }

.search-heading h2 {
  margin: 0;
  font-size: clamp(25px, 3vw, 38px);
  line-height: 1.2;
  font-weight: 650;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  align-items: end;
  gap: 12px;
  width: 100%;
  max-width: none;
}

.input-wrap { position: relative; }

.input-wrap label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
}

.input-wrap input {
  width: 100%;
  height: 54px;
  padding: 0 150px 0 16px;
  border: 1px solid #aeb6bd;
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  font-size: 18px;
  text-transform: uppercase;
  outline: none;
}

.input-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 107, 99, 0.12);
}

.input-wrap.has-error input { border-color: var(--danger); }

.input-hint {
  position: absolute;
  right: 14px;
  bottom: 18px;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
}

.search-form button {
  height: 54px;
  border: 0;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.search-form button:hover { background: var(--accent-dark); }
.search-form button:disabled { opacity: 0.7; cursor: wait; }

.alert {
  grid-column: 2;
  max-width: 780px;
  margin-top: 14px;
  padding: 12px 14px;
  border-left: 3px solid var(--danger);
  background: var(--danger-soft);
  color: #7a271a;
  font-size: 14px;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 30px;
  padding: 34px 0 24px;
}

.part-number {
  margin: 0 0 7px;
  color: var(--accent);
  font-family: Consolas, monospace;
  font-size: 15px;
  font-weight: 700;
}

.result-header h2 { margin: 0; font-size: 28px; }

.result-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: 13px;
}

.result-meta strong { margin-left: 5px; color: var(--ink); }

.hazmat {
  padding: 5px 8px;
  border: 1px solid #e1a237;
  color: var(--warning);
  font-weight: 700;
}

.hazmat.is-clear { border-color: #86b99b; color: var(--success); }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric {
  min-width: 0;
  padding: 22px 20px;
  border-right: 1px solid var(--line);
}

.metric:first-child { padding-left: 0; }
.metric:last-child { border-right: 0; }
.metric p { margin: 0 0 9px; color: var(--muted); font-size: 13px; }
.metric strong { font-size: 27px; font-weight: 650; }
.metric span { margin-left: 5px; color: var(--muted); font-size: 12px; }
.metric .date-value { font-size: 21px; }
.price-primary strong { color: var(--accent); }
.stock-total strong { color: var(--success); }

.content-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.28fr);
  gap: 56px;
  padding: 42px 0 70px;
}

.data-section { min-width: 0; }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ink);
}

.section-title h3 { margin: 0; font-size: 18px; }
.section-title span { color: var(--muted); font-size: 10px; font-weight: 700; }

.detail-list { margin: 0; }

.detail-list div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 15px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.detail-list dt { color: var(--muted); font-size: 13px; }
.detail-list dd { margin: 0; text-align: right; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.number-cell { text-align: right; }
.number-cell strong { color: var(--success); font-size: 15px; }
.no-stock { color: #8b9298; }
.no-stock .number-cell strong { color: #8b9298; }
.empty-cell { padding: 28px; text-align: center; color: var(--muted); }

.empty-state {
  min-height: 330px;
  display: grid;
  align-content: center;
  justify-items: center;
  color: var(--muted);
}

.empty-code {
  color: #d9dee2;
  font-family: Consolas, monospace;
  font-size: clamp(27px, 5vw, 54px);
  font-weight: 700;
}

.empty-state p { margin: 14px 0 0; font-size: 14px; }

.source-section { padding: 30px 0 8px; }
.source-section + .source-section { margin-top: 18px; }
.source-tables-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 18px;
  padding-bottom: 70px;
}
.source-tables-grid .source-section { min-width: 0; margin-top: 18px; padding-bottom: 0; }
.source-section-title {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ink);
}
.source-section-title h3 { margin: 0; font-size: 20px; }
.source-section-title > div > span { color: var(--muted); font-size: 10px; font-weight: 700; }
.master-panels {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding-top: 14px;
}
.source-panel { min-width: 0; border: 1px solid var(--line); }
.source-panel h4 { margin: 0; padding: 13px 15px; background: var(--soft); font-size: 14px; }
.source-fields { margin: 0; padding: 5px 15px 12px; }
.source-fields.two-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
.source-fields div { min-width: 0; padding: 12px 0; }
.source-fields dt { margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.source-fields dd { min-height: 18px; margin: 0; font-size: 13px; font-weight: 650; overflow-wrap: anywhere; }
.boolean-box {
  width: 18px;
  height: 18px;
  display: inline-block;
  border: 1px solid #aeb6bd;
  background: #fff;
  vertical-align: middle;
}
.boolean-box.is-checked { position: relative; border-color: var(--accent); background: var(--accent); }
.boolean-box.is-checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.replacement-type { display: flex; align-items: center; gap: 10px; }
.replacement-type span { color: var(--muted); font-size: 12px; }
.replacement-type strong { min-width: 150px; padding: 9px 30px 9px 11px; border: 1px solid #aeb6bd; font-size: 12px; font-weight: 600; }
.source-table-wrap { border: 1px solid var(--line); border-top: 0; }
.source-table { min-width: 600px; table-layout: fixed; }
.source-table thead { background: #202326; color: #fff; }
.source-table th { color: #fff; }
.source-table tbody tr:nth-child(even) { background: var(--soft); }
.inventory-total { color: var(--muted); font-size: 12px; }
.inventory-total strong { margin: 0 4px; color: var(--success); font-size: 18px; }
.inventory-table { min-width: 600px; }
.inventory-source { padding-bottom: 0; }

@media (max-width: 850px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .metric:nth-child(3) { padding-left: 0; }
  .content-grid { grid-template-columns: 1fr; gap: 38px; }
  .master-panels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1240px) {
  .search-band { display: block; }
  .search-heading { margin-bottom: 22px; }
  .search-form, .alert { max-width: 780px; }
}

@media (max-width: 1100px) {
  .source-tables-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .shell { width: min(100% - 28px, 1180px); }
  .search-band { padding-top: 34px; }
  .search-form { grid-template-columns: 1fr; }
  .input-wrap input { padding-right: 16px; }
  .input-hint { display: none; }
  .result-header { align-items: flex-start; flex-direction: column; gap: 16px; }
  .result-meta { justify-content: flex-start; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { padding: 18px 12px; }
  .metric strong { font-size: 21px; }
  .metric .date-value { font-size: 16px; }
  .detail-list div { grid-template-columns: 100px minmax(0, 1fr); }
  th, td { padding-left: 8px; padding-right: 8px; }
  .master-panels { grid-template-columns: 1fr; }
  .source-section-title { align-items: flex-start; flex-direction: column; gap: 10px; }
  .replacement-type { width: 100%; justify-content: space-between; }
  .replacement-type strong { min-width: 180px; }
}
