* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: #f2f4f7;
  margin: 0;
  color: #1a1a1a;
}

header {
  background: #1e3a5f;
  color: white;
  padding: 20px 30px;
}
header h1 { margin: 0; font-size: 22px; }
header p { margin: 4px 0 0; opacity: 0.8; font-size: 13px; }

.tabs {
  display: flex;
  background: white;
  border-bottom: 1px solid #d8dee6;
  padding: 0 30px;
}
.tab {
  padding: 14px 20px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  font-weight: 600;
  color: #5a6572;
}
.tab.active {
  color: #1e3a5f;
  border-bottom-color: #4a90d9;
}

.panel { display: none; padding: 24px 30px; max-width: 900px; }
.panel.active { display: block; }
#suppliers.active, #catalog.active { max-width: 1100px; }
#configurator.active { max-width: 1400px; }

.configurator-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.configurator-form {
  flex: 1;
  min-width: 0;
}
.configurator-preview {
  width: 380px;
  flex-shrink: 0;
  position: sticky;
  top: 16px;
}
.configurator-preview .card {
  border-color: #4a90d9;
}
.configurator-preview .card h2 {
  margin-bottom: 12px;
}
.preview-placeholder {
  color: #8a94a3;
  font-size: 13px;
}

@media (max-width: 900px) {
  .configurator-layout { flex-direction: column; }
  .configurator-preview { width: 100%; position: static; }
}

.card {
  background: white;
  border: 1px solid #d8dee6;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.card h2 { margin-top: 0; font-size: 16px; color: #1e3a5f; }

.cce-section {
  border-top: 1px solid #e5e9ef;
  padding-top: 16px;
  margin-top: 16px;
}
.cce-section:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.cce-section h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5a6572;
}

.row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.field { flex: 1; min-width: 160px; }
.product-autocomplete-wrap { position: relative; }
.autocomplete-dropdown {
  display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  max-height: 220px; overflow-y: auto;
  background: #fff; border: 1px solid #c3cbd6; border-top: none; border-radius: 0 0 4px 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.autocomplete-dropdown.open { display: block; }
.autocomplete-item {
  padding: 8px 10px; font-size: 14px; cursor: pointer;
}
.autocomplete-item:hover, .autocomplete-item.active { background: #e8f0fe; }
.autocomplete-item .sku-hint { font-size: 11px; color: #8a95a3; margin-left: 6px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: #5a6572; margin-bottom: 4px; }
.field input, .field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #c3cbd6;
  border-radius: 4px;
  font-size: 14px;
}

button {
  background: #4a90d9;
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 5px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
button:hover { background: #3a7bc0; }

.view-toggle { display: flex; gap: 8px; margin-bottom: 14px; }
.view-toggle button.inactive { background: #dbe4ee; color: #5a6572; }

table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #e5e9ef; font-size: 14px; }
th { background: #eaf1fa; color: #1e3a5f; }

.total-row td { font-weight: 700; font-size: 16px; border-top: 2px solid #1e3a5f; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 700; background: #d6e8ff; color: #1d4ed8; }

.note { font-size: 12px; color: #8a94a3; margin-top: 8px; }

table button { padding: 5px 10px; font-size: 12px; }

.landed-cost-line {
  background: #eaf1fa;
  border: 2px solid #1e3a5f;
  border-radius: 6px;
  padding: 14px 18px;
  margin: 16px 0;
  font-size: 18px;
  font-weight: 700;
  color: #1e3a5f;
}

/* Formula snackbar */
.formula-snackbar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e3a5f;
  color: white;
  padding: 16px 24px;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  z-index: 1000;
  font-size: 14px;
  max-width: 600px;
  line-height: 1.6;
}
.formula-snackbar .formula-title {
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 15px;
}
.formula-snackbar .formula-body span.formula-val {
  background: #4a90d9;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
.formula-snackbar .formula-body span.formula-val:hover {
  background: #3a7bc0;
}
.formula-snackbar .formula-body span.formula-val-static {
  background: #6b7a8d;
  cursor: default;
}
.formula-snackbar .formula-body span.formula-val-static:hover {
  background: #6b7a8d;
}
.formula-snackbar .formula-source {
  font-size: 11px;
  color: #a0b4cc;
  margin-top: 6px;
}
.formula-snackbar .formula-close {
  position: absolute;
  top: 8px;
  right: 12px;
  cursor: pointer;
  font-size: 18px;
  color: #a0b4cc;
}
.formula-snackbar .formula-close:hover { color: white; }

/* Blink highlight for referenced values */
@keyframes blink-red-box {
  0%, 100% { outline: 3px solid red; outline-offset: 2px; }
  50% { outline: 3px solid transparent; outline-offset: 2px; }
}
.blink-highlight {
  animation: blink-red-box 0.6s ease-in-out 5;
}

/* Make preview rows clickable */
tr[data-formula] { cursor: pointer; }
tr[data-formula]:hover { background: #f0f5ff; }

/* Input with icon button */
.input-with-icon { display: flex; gap: 4px; align-items: center; }
.input-with-icon input { flex: 1; }
.icon-btn {
  padding: 6px 8px; font-size: 16px; line-height: 1; border: 1px solid #c3cbd6;
  border-radius: 4px; background: #f5f7fa; cursor: pointer;
}
.icon-btn:hover { background: #e8f0fe; }

/* Shipping popup modal */
.popup-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center;
}
.popup-card {
  background: #fff; border-radius: 8px; padding: 24px; max-width: 700px; width: 90%;
  max-height: 85vh; overflow-y: auto; position: relative; box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.popup-card h2 { margin-top: 0; font-size: 16px; color: #1e3a5f; }
.popup-close {
  position: absolute; top: 12px; right: 16px; font-size: 22px; cursor: pointer;
  color: #8a95a3; background: none; border: none;
}
.popup-close:hover { color: #1e3a5f; }
