/* Route Marketplace — shares the purple-on-white brand language used by the
   portal's public signup pages (portal/public/signup-theme.css) so a supplier
   who has seen one recognises the other. Kept as its own file rather than
   imported: the marketplace is a separate process and must not break if the
   portal's theme is restyled. */

:root {
  --bg: #ffffff;
  --bg2: #faf8ff;
  --surface: #f6f2ff;
  --border: #e6dff5;
  --border-strong: #d3c6ee;
  --accent: #6d28d9;
  --accent-light: #f3e8ff;
  --accent-dark: #4c1d95;
  --text: #1a0a2e;
  --muted: #5a4f70;
  --muted2: #9088a3;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --ok: #16a34a;
  --ok-bg: #f0fdf4;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --shadow: 0 2px 20px rgba(109, 40, 217, .08);
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Chrome ─────────────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 24px;
  height: 64px; padding: 0 24px;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav .brand { font-weight: 800; font-size: 17px; letter-spacing: -.02em; color: var(--accent-dark); }
.nav .brand span { color: var(--accent); }
.nav .links { display: flex; gap: 18px; margin-left: auto; align-items: center; }
.nav .links a { color: var(--muted); font-size: 14px; font-weight: 600; }
.nav .links a.active, .nav .links a:hover { color: var(--accent); text-decoration: none; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 24px 80px; }
.wrap.narrow { max-width: 460px; padding-top: 56px; }

h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 6px; }
h2 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 4px; }
h3 { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted2); margin-bottom: 10px; }
.sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }

/* ── Surfaces ───────────────────────────────────────────────────────── */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.panel { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }

/* ── Forms ──────────────────────────────────────────────────────────── */
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: 9px;
  font-family: inherit; font-size: 14px; color: var(--text); background: var(--bg);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
textarea { resize: vertical; min-height: 76px; }
.field { margin-bottom: 15px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.hint { font-size: 12px; color: var(--muted2); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); font-weight: 500; margin-bottom: 8px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 18px; border: none; border-radius: 9px;
  background: var(--accent); color: #fff;
  font-family: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
button:hover, .btn:hover { background: var(--accent-dark); text-decoration: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost, .btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--border-strong); }
button.ghost:hover { background: var(--accent-light); }
button.sm { padding: 6px 12px; font-size: 13px; }
button.danger { background: var(--danger); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Feedback ───────────────────────────────────────────────────────── */
.msg { padding: 11px 14px; border-radius: 9px; font-size: 13.5px; margin-bottom: 16px; display: none; }
.msg.show { display: block; }
.msg.err { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.msg.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #bbf7d0; }
.msg.info { background: var(--warn-bg); color: var(--warn); border: 1px solid #fde68a; }

/* ── Enhanced form controls (market/public/ui.js) ───────────────────── */
/* The native <select> stays in the DOM as the source of truth and is visually
   hidden; the trigger + popup below are painted on top of it. */
.mk-select { position: relative; }
.mk-select .mk-native { position: absolute; opacity: 0; pointer-events: none; width: 100%; height: 100%; }

.mk-trigger {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 9px;
  font-family: inherit; font-size: 14px; font-weight: 500; text-align: left;
}
.mk-trigger:hover { background: var(--bg); border-color: var(--accent); }
.mk-select.open .mk-trigger { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.mk-trigger .mk-val { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.mk-trigger .mk-caret {
  margin-left: auto; flex: 0 0 auto; color: var(--muted);
  font-size: 15px; line-height: 1; transition: transform .12s;
}
.mk-select.open .mk-trigger .mk-caret { transform: rotate(180deg); color: var(--accent); }
.mk-ph { color: var(--muted2); font-weight: 400; }
.mk-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-code { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--muted2); letter-spacing: .04em; }
.mk-icon { width: 18px; text-align: center; flex: 0 0 18px; }

/* Overrides flag-icons' own .fi sizing — market.css is linked after it, and
   both are single-class selectors, so these win. display is set explicitly
   because .mk-flag-none carries no .fi class to inherit it from. */
.mk-flag {
  display: inline-block; vertical-align: middle;
  width: 20px; height: 15px; flex: 0 0 20px; border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .08); background-size: cover;
}
.mk-flag-none { background: var(--surface); }

.mk-pop {
  display: none; position: absolute; left: 0; right: 0; top: calc(100% + 5px); z-index: 60;
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: 11px;
  box-shadow: 0 12px 34px rgba(26, 10, 46, .16); overflow: hidden;
}
.mk-select.open .mk-pop { display: block; }
.mk-select.up .mk-pop { top: auto; bottom: calc(100% + 5px); }

.mk-search { padding: 9px; border-bottom: 1px solid var(--border); }
.mk-search input { width: 100%; padding: 8px 10px; font-size: 13.5px; border-radius: 7px; }
.mk-list { max-height: 240px; overflow-y: auto; padding: 5px; }
.mk-opt {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 7px; font-size: 14px; cursor: pointer;
}
.mk-opt:hover, .mk-opt.cur { background: var(--accent-light); }
.mk-opt.on { font-weight: 700; color: var(--accent-dark); }
.mk-empty { padding: 16px 12px; text-align: center; color: var(--muted2); font-size: 13px; }

/* ── File dropzone ──────────────────────────────────────────────────── */
.mk-file-native { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.mk-drop {
  position: relative; display: flex; align-items: center; gap: 13px;
  min-height: 76px; padding: 14px 16px; cursor: pointer;
  border: 1.5px dashed var(--border-strong); border-radius: 11px;
  background: var(--bg2); transition: border-color .12s, background .12s;
}
.mk-drop:hover { border-color: var(--accent); background: var(--accent-light); }
/* Dragging over: solid border + filled, so the drop target is unmistakable. */
.mk-drop.over { border-style: solid; border-color: var(--accent); background: var(--accent-light); }
.mk-drop.filled { border-style: solid; border-color: var(--ok); background: var(--ok-bg); cursor: default; }
.mk-drop.bad { border-color: var(--danger); background: var(--danger-bg); }

.mk-drop-body { display: flex; align-items: center; gap: 13px; width: 100%; min-width: 0; }
.mk-drop-icon { font-size: 22px; flex: 0 0 auto; line-height: 1; }
.mk-drop-copy { flex: 1; min-width: 0; }
.mk-drop-cta { font-size: 14px; font-weight: 600; color: var(--text); }
.mk-drop.bad .mk-drop-cta { color: var(--danger); }
.mk-drop-cta u { color: var(--accent); text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
.mk-drop-hint { font-size: 12px; color: var(--muted2); margin-top: 2px; }
.mk-file-name { font-size: 14px; font-weight: 700; color: var(--text);
                overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mk-thumb {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 21px; background: var(--bg); border: 1px solid var(--border); overflow: hidden;
}
.mk-thumb.img { padding: 0; }
.mk-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.mk-file-x {
  flex: 0 0 auto; background: none; border: none; color: var(--muted2);
  font-size: 20px; line-height: 1; padding: 5px 8px; border-radius: 7px; cursor: pointer;
}
.mk-file-x:hover { background: rgba(220, 38, 38, .1); color: var(--danger); }

/* Password field with a reveal toggle. */
.mk-pw { position: relative; display: flex; }
.mk-pw input { padding-right: 42px; }
.mk-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted2);
  padding: 6px 8px; font-size: 15px; line-height: 1; cursor: pointer; border-radius: 7px;
}
.mk-eye:hover { background: var(--accent-light); }

.mk-meter { font-size: 12px; color: var(--muted2); margin-top: 4px; }
.mk-meter.weak { color: var(--danger); }
.mk-meter.ok { color: var(--warn); }
.mk-meter.good { color: var(--ok); }

/* ── Tags / badges ──────────────────────────────────────────────────── */
.tag {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .01em;
  background: var(--surface); color: var(--accent-dark); border: 1px solid var(--border);
}
.tag.ok { background: var(--ok-bg); color: var(--ok); border-color: #bbf7d0; }
.tag.warn { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }
.tag.err { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.tag.mut { background: #f4f4f5; color: var(--muted); border-color: #e4e4e7; }

.band { font-weight: 800; width: 26px; height: 26px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.band.A { background: var(--ok-bg); color: var(--ok); }
.band.B { background: var(--warn-bg); color: var(--warn); }
.band.C { background: var(--danger-bg); color: var(--danger); }
.band.Untested { background: #f4f4f5; color: var(--muted2); font-size: 11px; }

/* ── Listing grid ───────────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.listing { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; transition: border-color .12s, transform .12s; }
.listing:hover { border-color: var(--accent); transform: translateY(-1px); }
.listing .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.listing .country { font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.listing .price { font-size: 21px; font-weight: 800; color: var(--accent); letter-spacing: -.02em; }
.listing .price small { font-size: 11px; font-weight: 700; color: var(--muted2); display: block; text-align: right; letter-spacing: .04em; }
.listing .facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; margin: 12px 0; }
.listing .facts dt { color: var(--muted2); font-weight: 600; }
.listing .facts dd { color: var(--text); }
.listing .tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; }

/* ── Tables ─────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted2); padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }

/* ── Filter bar ─────────────────────────────────────────────────────── */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 20px; }
.filters .field { margin-bottom: 0; min-width: 130px; }

/* ── Modal ──────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(26, 10, 46, .45); display: none; align-items: flex-start; justify-content: center; padding: 40px 20px; overflow-y: auto; z-index: 100; }
.modal.show { display: flex; }
.modal .box { background: var(--bg); border-radius: 14px; padding: 24px; width: 100%; max-width: 620px; box-shadow: 0 20px 60px rgba(26, 10, 46, .25); }
.modal .box.wide { max-width: 860px; }
.modal .head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal .close { background: none; color: var(--muted2); font-size: 22px; padding: 0 6px; line-height: 1; }
.modal .close:hover { background: none; color: var(--text); }

/* ── Chat thread ────────────────────────────────────────────────────── */
.thread { max-height: 340px; overflow-y: auto; padding: 4px; display: flex; flex-direction: column; gap: 9px; }
.bubble { padding: 9px 13px; border-radius: 11px; font-size: 13.5px; max-width: 82%; }
.bubble.them { background: var(--surface); align-self: flex-start; }
.bubble.me { background: var(--accent); color: #fff; align-self: flex-end; }
.bubble .who { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; opacity: .6; margin-bottom: 2px; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted2); font-size: 14px; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 12.5px; }
.sep { height: 1px; background: var(--border); margin: 18px 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

@media (max-width: 640px) {
  .row, .row3 { grid-template-columns: 1fr; }
  .nav { padding: 0 14px; gap: 12px; }
  .nav .links { gap: 12px; }
  .wrap { padding: 20px 14px 60px; }
}
