:root {
  --bg: #eef3fb;
  --panel: #ffffff;
  --panel-2: #f4f8ff;
  --line: #d8e3f7;
  --text: #16243f;
  --muted: #6b7a99;
  --accent: #2563eb;
  --accent-2: #0ea5e9;
  --accent-soft: #e7efff;
  --ok: #16a34a;
  --ok-soft: #e4f7ec;
  --warn: #d97706;
  --warn-soft: #fdf0dd;
  --err: #dc2626;
  --err-soft: #fde6e6;
  --radius: 12px;
  --shadow: 0 4px 18px rgba(37,99,235,.08);
  --dock-h: 230px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  padding-bottom: calc(var(--dock-h) + 16px);
}

/* topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 20px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.logo { font-size: 22px; font-weight: 800; letter-spacing: .5px; color: var(--text); }
.logo .accent { color: var(--accent); }
.subtitle { color: var(--muted); font-size: 13px; }
.global-reqs { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.req-group { display: flex; align-items: center; gap: 6px; }
.req-group label { color: var(--muted); font-size: 12px; }
.req-group input { width: 66px; }

input, select {
  background: #fff; border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 6px 8px; font-size: 13px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.btn {
  background: #fff; border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 8px 14px; cursor: pointer; font-size: 13px;
  transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; color: #fff; font-weight: 600; }
.btn-primary:hover { color: #fff; filter: brightness(1.05); }
.btn-ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
/* prominent header CTAs */
.btn-header { align-self: center; text-decoration: none; }
.btn-feedback {
  margin-left: 6px; background: #fff; border: 1px solid var(--accent);
  color: var(--accent); font-weight: 600; align-self: center;
}
.btn-feedback:hover { background: var(--accent); color: #fff; }

/* workspace */
.workspace {
  display: grid; grid-template-columns: 340px 1fr; gap: 16px;
  padding: 16px 20px; align-items: start;
}
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 12px; font-size: 15px; }

/* categories */
.categories ul { list-style: none; margin: 0; padding: 0; }
.cat-row {
  display: flex; align-items: center; gap: 10px; padding: 10px;
  border: 1px solid transparent; border-radius: 10px; cursor: pointer; margin-bottom: 4px;
}
.cat-row:hover { background: var(--panel-2); }
.cat-row.active { background: var(--accent-soft); border-color: var(--accent); }
.cat-status { width: 10px; height: 10px; border-radius: 50%; background: #cdd8ec; flex: none; }
.cat-status.filled { background: var(--ok); }
.cat-status.error { background: var(--err); }
.cat-status.warn { background: var(--warn); }
.cat-info { flex: 1; min-width: 0; }
.cat-name { font-weight: 600; }
.cat-name .req-star { color: var(--accent); }
.cat-sel { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-actions { display: flex; gap: 4px; }
.icon-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 4px; border-radius: 6px; }
.icon-btn:hover { color: var(--text); background: var(--line); }
.icon-btn.locked { color: var(--warn); }

.evaluation { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.metric { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.metric .m-label { color: var(--muted); font-size: 11px; }
.metric .m-value { font-size: 16px; font-weight: 700; }
.tip-hint { font-size: 11px; color: var(--muted); margin-top: 2px; }
.issue-list { display: flex; flex-direction: column; gap: 6px; }
.issue {
  display: flex; gap: 8px; padding: 8px 10px; border-radius: 8px; font-size: 12px;
  border-left: 3px solid var(--line); background: var(--panel-2);
}
.issue.error { border-left-color: var(--err); background: var(--err-soft); }
.issue.warning { border-left-color: var(--warn); background: var(--warn-soft); }
.issue.suggestion { border-left-color: var(--accent); background: var(--accent-soft); }
.issue .i-title { font-weight: 600; }
.issue .i-exp { color: var(--muted); }
.badge { font-size: 10px; padding: 1px 7px; border-radius: 999px; font-weight: 700; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }

/* candidates */
.candidates-head { display: flex; align-items: center; justify-content: space-between; }
.checkbox { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; }
.search-row { margin-top: 10px; }
#candSearch {
  width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; background: #fff;
}
#candSearch:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.cand-body { display: grid; grid-template-columns: 230px 1fr; gap: 16px; margin-top: 12px; }
.filters { display: flex; flex-direction: column; gap: 12px; }
.filter { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.filter .f-head { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.filter .lock { color: var(--warn); font-size: 10px; }
.filter .f-values { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  font-size: 11px; padding: 3px 8px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip.disabled { opacity: .4; cursor: not-allowed; text-decoration: line-through; }
.chip.disabled:hover { border-color: var(--line); }
.range-inputs { display: flex; align-items: center; gap: 4px; }
.range-inputs input { width: 64px; }
.f-compat { font-size: 10px; color: var(--warn); margin-top: 4px; }

.cand-list { display: flex; flex-direction: column; gap: 10px; max-height: 64vh; overflow-y: auto; padding-right: 4px; }
.hint { color: var(--muted); }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
.card:hover { box-shadow: var(--shadow); }
.card.selected { border-color: var(--accent); background: var(--accent-soft); }
.card.incompatible { opacity: .82; }
.card-top { display: flex; gap: 10px; }
.card-thumb {
  width: 72px; height: 72px; flex: 0 0 72px; object-fit: contain;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.card-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.card-name { font-weight: 600; }
.card-brand { color: var(--muted); font-size: 12px; }
.card-price { font-size: 17px; font-weight: 800; color: var(--accent); white-space: nowrap; }
.card-meta { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.card-meta b { color: var(--text); }
.card-issues { display: flex; flex-direction: column; gap: 4px; }
/* per-candidate check chips (match/restriction terms) */
.check-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  font-size: 11px; line-height: 1.5; padding: 1px 7px; border-radius: 999px;
  border: 1px solid; cursor: default; white-space: nowrap; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis;
}
.chip.spec       { color: #23456e; background: #eef4fc; border-color: #c4d8f2; }
.chip.suggestion { color: #7a6205; background: #fdf6d8; border-color: #ecd97a; }
/* problem/suggestion chips expand to show the concrete reason */
.chip.detail {
  white-space: normal; text-align: left; width: 100%; border-radius: 8px;
  font-weight: 600; line-height: 1.35; padding: 4px 8px;
}
.chip-exp { display: block; font-weight: 400; opacity: .9; margin-top: 1px; }
.chip.ok      { color: #116932; background: #eafaf0; border-color: #b5e6c8; }
.chip.unk     { color: #6b5d1f; background: #fdf7e2; border-color: #e8d99a; }
.chip.warning { color: #92500a; background: #fef3e2; border-color: #f3d5a7; }
.chip.error   { color: #a51f2c; background: #fdecee; border-color: #f2b8bf; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.merchants { display: flex; gap: 8px; flex-wrap: wrap; font-size: 11px; }
.merchants a { color: var(--accent); text-decoration: none; }
.merchants a:hover { text-decoration: underline; }

/* bottom dock */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--dock-h);
  background: var(--panel); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 18px rgba(37,99,235,.10); z-index: 30;
  display: flex; flex-direction: column; transition: height .2s;
}
.dock.collapsed { height: 42px; }
.dock.dragging { transition: none; }
.dock-resize {
  position: absolute; top: 0; left: 0; right: 0; height: 8px; cursor: ns-resize;
  z-index: 2;
}
.dock-resize::before {
  content: ""; position: absolute; top: 3px; left: 50%; transform: translateX(-50%);
  width: 44px; height: 3px; border-radius: 2px; background: var(--line);
}
.dock-resize:hover::before { background: var(--accent); }
.dock-tabs { display: flex; align-items: center; gap: 4px; padding: 4px 12px; border-bottom: 1px solid var(--line); }
.dock-tab {
  background: none; border: none; cursor: pointer; padding: 8px 14px; font-size: 13px;
  color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600;
}
.dock-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.dock-badge { background: var(--accent); color: #fff; border-radius: 999px; font-size: 10px; padding: 1px 6px; margin-left: 4px; }
.dock-collapse { margin-left: auto; background: none; border: none; cursor: pointer; font-size: 16px; color: var(--muted); }
.dock-body { flex: 1; overflow-y: auto; padding: 12px 16px; }
.dock.collapsed .dock-body { display: none; }
.dock-pane { display: none; }
.dock-pane.active { display: block; }

.cart-grid { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.bucket { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 240px; flex: 1; }
.bucket .bk-head { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 6px; }
.bucket table { width: 100%; border-collapse: collapse; font-size: 12px; }
.bucket td { padding: 3px 0; border-bottom: 1px solid var(--line); }
.bucket td:last-child { text-align: right; white-space: nowrap; }
.bucket a { color: var(--accent); text-decoration: none; }
.cart-summary { display: flex; gap: 18px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.cart-summary .total { font-size: 18px; font-weight: 800; color: var(--accent); }

.build-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.build-card .b-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.build-card .b-head h3 { margin: 0; font-size: 14px; }
.build-card .b-metrics { display: flex; gap: 16px; color: var(--muted); font-size: 13px; margin-bottom: 8px; flex-wrap: wrap; }
.build-card .b-metrics b { color: var(--text); }
.build-card .b-parts { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 2px 16px; font-size: 12px; }
.b-part { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.b-part .p-cat { color: var(--muted); }
.note { color: var(--warn); font-size: 13px; margin-bottom: 12px; }

.toast {
  position: fixed; bottom: calc(var(--dock-h) + 18px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 80;
  box-shadow: var(--shadow);
}

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .cand-body { grid-template-columns: 1fr; }
  .build-card .b-parts { grid-template-columns: 1fr 1fr; }
}

/* ---------------------------------------------------------------- update_7 */
.brand-logo { height: 44px; border-radius: 8px; display: block; }

.footer {
  display: flex; gap: 22px; justify-content: center; padding: 14px;
  border-top: 1px solid var(--line); background: #fff; font-size: 13px;
  margin-top: 8px;
}
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--accent); }

.overlay {
  position: fixed; inset: 0; background: rgba(15, 30, 60, .45); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
/* the explicit display:flex above would defeat the hidden attribute */
.overlay[hidden] { display: none; }
.modal {
  background: #fff; border-radius: 12px; padding: 20px; max-width: 720px;
  width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px;
}
.checkout-modal { max-width: 900px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { font-size: 18px; }
.modal textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px;
  font: inherit; resize: vertical;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal .bucket table { width: 100%; }

/* feedback dialog */
.fb-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 4px; }
.modal input[type="text"] {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font: inherit;
}
.fb-choose-row { display: flex; align-items: center; gap: 10px; }
.fb-choose { display: inline-block; padding: 7px 14px; }
.fb-files { display: flex; flex-direction: column; gap: 4px; }
.fb-file { font-size: 12px; color: var(--text); }
.fb-file span { color: var(--muted); }
.fb-file.bad { color: #b91c1c; }
.fb-file.bad span { color: #b91c1c; }
.fb-err { font-size: 12px; color: #b91c1c; }

/* terms pop-up bullet points */
.terms-points { margin: 4px 0 4px 18px; display: flex; flex-direction: column; gap: 6px; }
.terms-points li { font-size: 14px; }

/* cart quantity controls + needed/spare split */
.qty-cell { white-space: nowrap; }
.qty-btn {
  width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 13px; line-height: 1;
}
.qty-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.qty-btn:disabled { opacity: .35; cursor: not-allowed; }
.qty-note { font-size: 11px; color: var(--muted); }
.head-checks { display: flex; gap: 16px; align-items: center; }

/* whole-build metrics strip in the cart (same params as generated builds) */
.cart-metrics {
  display: flex; gap: 22px; flex-wrap: wrap; padding: 8px 12px; margin: 8px 0;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
}
.cm { display: flex; align-items: baseline; gap: 6px; font-size: 12px; color: var(--muted); }
.cm b { font-size: 15px; color: var(--text); }
.cm-h { font-size: 10px; color: var(--muted); }

/* ground-station divider in the category list */
.cat-divider {
  list-style: none; margin: 10px 0 6px; padding: 6px 10px 4px;
  border-top: 2px dashed var(--line); color: var(--muted);
  font-size: 11px; font-weight: 600; letter-spacing: .3px;
}

/* generate-build option checkboxes (between Generate and Reset) */
.gen-opts { display: flex; flex-direction: column; gap: 2px; }
.gen-opts .checkbox { font-size: 12px; }
