/* ===== Site theme — dark base, chrome wordmark, green accent ===== */
:root {
  --bg: #0e1618;
  --bg-2: #131e20;          /* brand background */
  --panel: #17262a;
  --panel-2: #1d3035;
  --well: #0c1416;          /* inset boxes */
  --line: #29444b;
  --line-soft: #223a40;
  --text: #eef4f5;
  --muted: #8fa6ab;
  --muted-2: #6f878d;
  --silver-1: #f4f6f7;
  --silver-2: #c4ccd0;
  --silver-3: #8b979c;
  --accent: #5fd66e;        /* live price / primary action */
  --accent-strong: #78e87f;
  --accent-dim: #1b8928;
  --accent-badge: #abf7a8;  /* active-PO total badge */
  --on-accent: #04200b;
  --gold: #e7c469;          /* hedge price */
  --danger: #ff5b3a;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --font: "Mulish", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --mono: "Consolas", "SFMono-Regular", ui-monospace, Menlo, monospace;
  --tabbar-h: 0px;
  /* Page side padding; never less than a notched phone's safe area in landscape. */
  --gutter-l: max(clamp(16px, 4vw, 40px), env(safe-area-inset-left));
  --gutter-r: max(clamp(16px, 4vw, 40px), env(safe-area-inset-right));
  /* Native controls (dropdown lists, scrollbars, pickers) in their dark variants. */
  color-scheme: dark;
  scrollbar-color: var(--line) transparent;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* Stop iOS from enlarging text when the phone is turned sideways. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* `hidden` must win over any display rule (e.g. a hidden flex/grid container). */
[hidden] { display: none !important; }
body {
  background:
    radial-gradient(1200px 600px at 80% -10%, #1b2e33 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 10%, #16262b 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.45;
  min-height: 100vh;
  padding-bottom: var(--tabbar-h);
}
/* A fixed background repaints on every scroll on phones; only desktops keep it still. */
@media (hover: hover) and (pointer: fine) { body { background-attachment: fixed; } }
a { color: inherit; text-decoration: none; }
img { display: block; }
button, input, select { font-family: inherit; }
/* The same look in every browser: no iOS inner shadows or native dropdown chrome. */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), textarea { -webkit-appearance: none; appearance: none; }
select:not([multiple]) {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238fa6ab' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
}
select option { background-color: var(--panel); color: var(--text); }
/* Number spinners overlap the input suffixes and are fiddly on touch. */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chrome {
  background: linear-gradient(180deg, var(--silver-1) 0%, var(--silver-2) 45%, var(--silver-3) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.mono { font-family: var(--mono); }

/* ===== Top bar & tabs ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px var(--gutter-r) 10px var(--gutter-l);
  background: rgba(14, 22, 24, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
/* The name is set by the admin: when the header is short of room it wraps onto a
   second line, and only a name longer than that ends in "…". */
.brand { display: flex; align-items: center; gap: 12px; flex: 0 1 auto; min-width: 0; }
.brand-mark { width: 40px; height: 40px; border-radius: 9px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.brand-text strong {
  font-size: 19px;
  font-weight: 900;
  letter-spacing: .3px;
  line-height: 1.15;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
  background: linear-gradient(180deg, #fff, #b8c1c5);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-text em { font-style: normal; font-size: 11px; letter-spacing: 2px; color: var(--muted-2); text-transform: uppercase; }

.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs a, .bookmarks-link, .account-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.tabs svg, .bookmarks-link svg, .account-link svg {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.tabs a:hover, .bookmarks-link:hover, .account-link:hover { color: var(--text); background: var(--panel); }
.tabs a.active { color: var(--on-accent); background: linear-gradient(180deg, var(--accent-strong), var(--accent)); }
.bookmarks-link.active { color: var(--gold); background: var(--panel); }
.bookmarks-link.active svg { fill: currentColor; }
.account-link.active { color: var(--text); background: var(--panel); }
.po-badge, .credit-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 7px;
  border-radius: 999px; font-size: 11px; font-weight: 900;
  background: var(--accent-badge); color: #000618;
}
.po-badge[hidden], .credit-badge[hidden] { display: none; }

/* ===== Layout ===== */
.view { max-width: 1180px; margin: 0 auto; padding: clamp(20px, 4vw, 40px) var(--gutter-r) 64px var(--gutter-l); min-height: 60vh; }
.page-title { margin: 0 0 6px; font-size: clamp(22px, 3.4vw, 30px); font-weight: 900; letter-spacing: .3px; }
.page-sub { margin: 0 0 24px; color: var(--muted); }

/* ===== Hero / search ===== */
.hero { text-align: center; padding: 22px 0 6px; }
.hero h1 { font-size: clamp(28px, 5vw, 46px); font-weight: 900; margin: 0 0 8px; letter-spacing: .3px; line-height: 1.1; }
.hero p { color: var(--muted); margin: 0 auto 26px; max-width: 560px; }
.search-wrap { position: relative; max-width: 640px; margin: 0 auto; }
.searchbar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 7px 7px 20px;
  box-shadow: var(--shadow);
}
.searchbar:focus-within { border-color: var(--accent-dim); }
.searchbar > svg { flex: none; width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.searchbar input {
  flex: 1;
  align-self: stretch; /* the whole height of the bar is tappable */
  background: none;
  border: none;
  color: var(--text);
  font-size: 16px;
  outline: none;
  min-width: 0;
}
.searchbar input::placeholder { color: var(--muted-2); }
.searchbar.flat { box-shadow: none; max-width: none; }

/* Typeahead suggestions */
.suggest {
  position: absolute;
  z-index: 25;
  left: 0; right: 0; top: calc(100% + 8px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-align: left;
}
.suggest[hidden] { display: none; }
.suggest a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.suggest a:last-child { border-bottom: none; }
.suggest a:hover, .suggest a.hi { background: var(--panel-2); }
.suggest .make-logo { width: 34px; height: 34px; padding: 4px; }
.suggest .s-code { font-family: var(--mono); font-weight: 700; }
.suggest .s-make { color: var(--muted); font-size: 12px; }
.suggest .s-price { margin-left: auto; font-weight: 800; color: var(--accent); }
.suggest .s-price.locked { color: var(--muted-2); }
.suggest .s-price svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }
.suggest .s-all { justify-content: center; color: var(--accent); font-weight: 700; font-size: 14px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none;
  cursor: pointer;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: .4px;
  border-radius: 999px;
  padding: 11px 22px;
  color: var(--on-accent);
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  transition: transform .1s, filter .15s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--accent-dim); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid #5a2a22; }
.btn.small { padding: 8px 14px; font-size: 13px; }

/* ===== Stat strip ===== */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 34px auto 8px;
  max-width: 760px;
}
.stat {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat b { display: block; font-size: clamp(20px, 3vw, 28px); font-weight: 900; }
.stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }

/* ===== Section headers ===== */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 36px 0 16px;
}
.section-head h2 { margin: 0; font-size: 14px; font-weight: 900; letter-spacing: 1.6px; text-transform: uppercase; color: var(--silver-2); }
.section-head .count, .section-head a { color: var(--muted); font-size: 14px; font-weight: 600; }
.section-head a:hover { color: var(--accent); }

/* ===== Filter toolbar ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 16px 0;
}
.toolbar select, .toolbar input, .text-input {
  background-color: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  min-width: 0;
}
.toolbar select:focus, .toolbar input:focus, .text-input:focus { border-color: var(--accent-dim); }
.toolbar select { padding-right: 32px; } /* room for the arrow */
.toolbar input[type="number"] { width: 110px; }
.toolbar .spacer { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 8px 5px 12px; font-size: 13px; color: var(--silver-2);
}
.chip button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; }
.chip button:hover { color: var(--danger); }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; font-weight: 700; padding: 5px 4px; }

/* ===== Converter cards ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr));
  gap: 16px;
  transition: opacity .15s;
}
.grid.is-loading { opacity: .5; pointer-events: none; }
.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  transition: transform .12s, border-color .15s, box-shadow .15s;
  display: flex;
  flex-direction: column;
}
/* Hover effects only where there's a mouse: on touch screens they'd stick after a tap. */
@media (hover: hover) { .card:hover { transform: translateY(-3px); border-color: var(--accent-dim); box-shadow: var(--shadow); } }
.card-link { display: flex; flex-direction: column; gap: 12px; padding: 16px 16px 12px; flex: 1; border-radius: var(--radius) var(--radius) 0 0; }
.card-top { display: flex; align-items: center; gap: 12px; }
.make-logo {
  width: 46px; height: 46px; flex: none;
  object-fit: contain;
  background: var(--well);
  border-radius: 10px;
  border: 1px solid var(--line-soft);
  padding: 5px;
}
.make-logo.placeholder { display: flex; align-items: center; justify-content: center; font-weight: 900; color: var(--silver-3); font-size: 16px; }
.card-code { font-family: var(--mono); font-size: 15px; font-weight: 700; overflow-wrap: anywhere; line-height: 1.25; }
.card-make { color: var(--muted); font-size: 13px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--panel-2); color: var(--silver-2); border: 1px solid var(--line-soft);
}
.badge.generic { color: var(--gold); border-color: #5b4f2a; }
.badge.photo { color: var(--accent); border-color: #25502c; }
.prices { display: flex; gap: 10px; margin-top: auto; }
.price-box { flex: 1; background: var(--well); border: 1px solid var(--line-soft); border-radius: 10px; padding: 9px 12px; }
.price-box .label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--muted-2); }
.price-box .val { font-size: 20px; font-weight: 900; }
.price-box.live .val { color: var(--accent); }
.price-box.hedge .val { color: var(--gold); }
.price-box.locked .val { color: var(--muted-2); display: flex; align-items: center; height: 30px; }
.price-box .val svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.detail-prices .price-box.locked .val { height: 48px; }
.detail-prices .price-box .val svg { width: 26px; height: 26px; }
.thumb { width: 100%; height: 110px; object-fit: contain; padding: 6px; border-radius: 10px; background: var(--well); border: 1px solid var(--line-soft); }
.card-actions { display: flex; gap: 8px; padding: 0 16px 16px; }
.icon-btn {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 10px; padding: 8px; cursor: pointer; font-size: 13px; font-weight: 700;
  transition: color .15s, border-color .15s, background .15s;
}
.icon-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.icon-btn:hover { color: var(--text); border-color: var(--accent-dim); }
.icon-btn.on { color: var(--gold); border-color: #5b4f2a; }
.icon-btn.on svg { fill: currentColor; }
.icon-btn.added { color: var(--accent); border-color: var(--accent-dim); }
.icon-btn.unlock { color: var(--accent); border-color: var(--accent-dim); }
.icon-btn.unlock:hover { background: rgba(95, 214, 110, 0.08); }
.icon-btn:disabled { opacity: .6; cursor: progress; }

/* ===== Make grid ===== */
.make-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.make-card {
  display: block;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 20px 14px 16px;
  text-align: center;
  transition: transform .12s, border-color .15s;
}
@media (hover: hover) { .make-card:hover { transform: translateY(-3px); border-color: var(--accent-dim); } }
.make-card .make-logo { width: 64px; height: 64px; margin: 0 auto 12px; padding: 8px; font-size: 22px; }
.make-card b { display: block; font-size: 15px; font-weight: 800; }
.make-card span { display: block; color: var(--muted); font-size: 12px; }
.make-card .range { color: var(--muted-2); margin-top: 2px; }

/* ===== Pagination ===== */
.pager { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 30px; }
.pager button {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 9px 14px; cursor: pointer; font-weight: 700;
}
.pager button:hover:not(:disabled) { border-color: var(--accent-dim); }
.pager button:disabled { opacity: .4; cursor: not-allowed; }
.pager .page-info { color: var(--muted); font-size: 14px; padding: 0 6px; }

/* ===== States ===== */
.empty, .loading { text-align: center; color: var(--muted); padding: 56px 20px; grid-column: 1 / -1; }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 6px; }
.empty .btn { margin-top: 16px; }
.skeleton { background: linear-gradient(90deg, var(--panel) 25%, var(--panel-2) 37%, var(--panel) 63%); background-size: 400% 100%; animation: sh 1.4s infinite; border-radius: var(--radius); height: 230px; }
@keyframes sh { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4, 9, 10, 0.72); backdrop-filter: blur(4px); }
.modal-card {
  position: relative;
  width: min(720px, 100%);
  max-height: 90vh;
  max-height: 90dvh; /* the visible height, between a phone browser's toolbars */
  overflow: auto;
  overscroll-behavior: contain;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.modal-close { position: absolute; top: 12px; right: 14px; background: none; border: none; color: var(--muted); font-size: 30px; line-height: 1; cursor: pointer; z-index: 1; }
.modal-close:hover { color: var(--text); }

/* ===== Converter detail (modal + page) ===== */
.detail-page {
  max-width: 760px;
  margin: 0 auto;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
}
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 700; margin-bottom: 16px; }
.back-link:hover { color: var(--accent); }
.detail-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; padding-right: 30px; }
.detail-head .make-logo { width: 60px; height: 60px; }
.detail-head h3 { margin: 0; font-family: var(--mono); font-size: 22px; overflow-wrap: anywhere; line-height: 1.2; }
.gallery { margin-bottom: 18px; }
.gallery-main {
  width: 100%; height: 230px; object-fit: contain; padding: 10px;
  background: var(--well); border: 1px solid var(--line-soft); border-radius: 14px;
}
.gallery-bar { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.gallery-thumbs { display: flex; gap: 8px; overflow-x: auto; min-width: 0; }
.gallery-thumbs button { padding: 0; border: 2px solid transparent; border-radius: 10px; background: var(--well); cursor: pointer; flex: none; }
.gallery-thumbs button.on { border-color: var(--accent); }
.gallery-thumbs img { width: 72px; height: 56px; object-fit: contain; border-radius: 8px; }
.no-photo {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  height: 150px; margin-bottom: 18px;
  background: var(--well); border: 1px dashed var(--line); border-radius: 14px; color: var(--muted-2); font-size: 13px;
}
.no-photo img { width: 120px; opacity: .5; }
.detail-prices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.detail-prices .price-box { padding: 14px 16px; }
.detail-prices .price-box .val { font-size: 32px; }
.detail-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 16px 0; }
.detail-meta .row { background: var(--well); border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.detail-meta .k { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--muted-2); }
.detail-meta .v { font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.add-po {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 14px; margin: 18px 0 14px;
  background: var(--well); border: 1px solid var(--line-soft); border-radius: 12px;
}
.add-po .lbl { font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); width: 100%; }
.segmented { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.segmented button {
  border: none; background: none; color: var(--muted); font-weight: 800; font-size: 13px;
  padding: 7px 12px; border-radius: 999px; cursor: pointer;
}
.segmented button.on { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent-dim); }
.stepper { display: inline-flex; align-items: center; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.stepper button { width: 30px; height: 30px; border-radius: 50%; border: none; background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 17px; line-height: 1; }
.stepper button:hover { background: var(--line); }
.stepper span { min-width: 30px; text-align: center; font-weight: 800; }
.add-po .unit-price { color: var(--muted); font-size: 13px; }
.add-po .unit-price b { color: var(--accent); }
.add-po .btn { margin-left: auto; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hint { font-size: 13px; color: var(--muted-2); margin: 14px 0 0; }

/* ===== Calculator ===== */
.calc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.panel h3 { margin: 0 0 4px; font-size: 13px; font-weight: 900; letter-spacing: 1.6px; text-transform: uppercase; color: var(--silver-2); }
.panel .panel-sub { margin: 0 0 16px; color: var(--muted-2); font-size: 13px; }
.fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%;
  background-color: var(--well); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 11px 12px; font-size: 16px; outline: none;
}
.field textarea { font-family: inherit; line-height: 1.45; resize: vertical; min-height: 120px; }
.field select { padding-right: 32px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent-dim); }
.input-affix { position: relative; }
.input-affix input { padding-right: 34px; }
.input-affix .affix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted-2); font-size: 13px; pointer-events: none; }
.input-affix.pre input { padding-left: 26px; padding-right: 12px; }
.input-affix.pre .affix { left: 12px; right: auto; }
.weight-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 12px; margin-top: 12px; }
.calc-result { position: sticky; top: 86px; text-align: center; }
.calc-result .big { font-size: clamp(34px, 5vw, 44px); font-weight: 900; color: var(--accent); margin: 6px 0 14px; line-height: 1.1; }
.metal-rows { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.metal-row { display: flex; align-items: center; gap: 12px; background: var(--well); border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px 12px; }
.metal-sym { width: 34px; height: 34px; flex: none; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 13px; color: #10181a; }
.metal-sym.pt { background: linear-gradient(180deg, #f1f4f5, #aab4b8); }
.metal-sym.pd { background: linear-gradient(180deg, #e5e2da, #a39d8c); }
.metal-sym.rh { background: linear-gradient(180deg, #e9d6d9, #a88b90); }
.metal-row .m-name { font-weight: 700; font-size: 14px; }
.metal-row .m-sub { color: var(--muted-2); font-size: 12px; }
.metal-row .m-val { margin-left: auto; font-weight: 900; }
.calc-result .btn { width: 100%; margin-top: 14px; }

/* ===== Purchase order ===== */
.po-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.po-summary .stat b { color: var(--accent); }
.po-list { display: flex; flex-direction: column; gap: 10px; }
.po-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 16px;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 12px 14px;
}
.po-info { min-width: 0; }
.po-info a { font-family: var(--mono); font-weight: 700; overflow-wrap: anywhere; }
.po-info a:hover { color: var(--accent); }
.po-info .po-sub { color: var(--muted); font-size: 13px; }
.po-line-total { font-weight: 900; color: var(--accent); min-width: 84px; text-align: right; font-size: 17px; }
.po-remove { background: none; border: none; color: var(--muted-2); cursor: pointer; font-size: 24px; line-height: 1; padding: 0 4px; }
.po-remove:hover { color: var(--danger); }
.po-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.po-actions .spacer { flex: 1; }
.po-table { display: none; }

/* ===== Current markets (home) ===== */
.markets { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 14px; }
.market-tile {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 14px 16px;
}
.market-tile .m-name { font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.market-tile .m-price { font-size: 22px; font-weight: 900; }
.market-tile .m-price span { font-size: 13px; font-weight: 600; color: var(--muted-2); }
.market-tile .m-change { margin-left: auto; font-size: 13px; font-weight: 800; white-space: nowrap; }
.m-change.up { color: var(--accent); }
.m-change.down { color: var(--danger); }
.markets + .hint { margin-top: 10px; }

/* ===== Paywall ===== */
.unlock-panel {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-top: 14px; padding: 16px 18px;
  background: linear-gradient(180deg, rgba(95, 214, 110, 0.08), rgba(95, 214, 110, 0.02));
  border: 1px solid var(--accent-dim); border-radius: 12px;
}
.unlock-copy { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: min(200px, 100%); }
.unlock-copy b { font-size: 16px; }
.unlock-copy span { color: var(--muted); font-size: 14px; }
.hero-cta { margin: 16px 0 0; color: var(--muted); font-size: 15px; }
.hero-cta a { color: var(--accent); font-weight: 800; }
.hero-cta a:hover { text-decoration: underline; }

.notice {
  margin: 0 0 18px; padding: 12px 16px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--panel);
  font-size: 14px; color: var(--silver-2);
}
.notice.info { border-color: #2b4e6b; background: rgba(51, 102, 255, 0.07); }
.notice.warn { border-color: #5b4f2a; background: rgba(231, 196, 105, 0.07); color: #efd999; }
.notice.success { border-color: var(--accent-dim); background: rgba(95, 214, 110, 0.08); color: #bdf2c3; }
.notice a { color: inherit; text-decoration: underline; }
.notice code, .page-sub code, .panel-sub code { background: var(--well); padding: 1px 6px; border-radius: 6px; font-size: .92em; }
.form-error { color: var(--danger); font-weight: 700; font-size: 14px; margin: 0 0 12px; }
.field .help { font-size: 12px; color: var(--muted-2); }
.field .help:empty { display: none; }

/* Sign in / create account */
.auth-wrap { display: flex; justify-content: center; padding: 12px 0 24px; }
.auth-card { width: min(440px, 100%); padding: 28px; text-align: center; }
.auth-mark { width: 56px; height: 56px; border-radius: 12px; margin: 0 auto 16px; }
.auth-tabs { margin-bottom: 20px; }
.auth-card .page-title { font-size: 26px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.auth-form .btn { width: 100%; padding: 13px 22px; margin-top: 4px; }
.auth-card .hint a { color: var(--accent); font-weight: 700; }

/* Buy searches */
.pricing-head { max-width: 640px; }
.balance-line { color: var(--muted); margin: 0 0 18px; }
.balance-line b { color: var(--text); }
.plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 16px; margin-bottom: 18px; }
.plan-card {
  position: relative;
  display: flex; flex-direction: column; gap: 6px;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 22px 20px 20px;
}
.plan-card.best { border-color: var(--accent-dim); box-shadow: 0 0 0 1px var(--accent-dim), var(--shadow); }
.plan-tag {
  position: absolute; top: -11px; left: 20px;
  background: linear-gradient(180deg, var(--accent-strong), var(--accent)); color: var(--on-accent);
  font-size: 11px; font-weight: 900; letter-spacing: .8px; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px;
}
.plan-name { font-size: 13px; font-weight: 900; letter-spacing: 1.4px; text-transform: uppercase; color: var(--silver-2); }
.plan-searches { font-size: 16px; color: var(--muted); }
.plan-searches b { font-size: 34px; font-weight: 900; color: var(--text); }
.plan-price { font-size: 26px; font-weight: 900; color: var(--accent); }
.plan-per { font-size: 13px; color: var(--muted-2); margin-bottom: 10px; }
.plan-card .btn { margin-top: auto; }

/* Account */
.account-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; margin-bottom: 8px; }
.account-grid .panel { margin-bottom: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.account-grid .k { font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.balance-card .big { font-size: 46px; font-weight: 900; color: var(--accent); line-height: 1.1; }
.balance-card .s { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.account-card .email { font-size: 17px; overflow-wrap: anywhere; margin-bottom: 8px; }
.account-card .btn { margin-top: auto; }

/* Tables (account history, admin) */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
}
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; color: var(--muted);
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--tabbar-h)); transform: translateX(-50%);
  z-index: 60;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--accent-dim);
  border-radius: 999px; padding: 10px 18px; font-weight: 700; font-size: 14px;
  box-shadow: var(--shadow);
  width: max-content; max-width: calc(100vw - 32px); text-align: center;
}
.toast[hidden] { display: none; }

/* ===== Footer ===== */
.footer {
  border-top: 1px solid var(--line-soft);
  padding: 26px var(--gutter-r) 26px var(--gutter-l);
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  color: var(--muted); font-size: 13px;
}
.footer-mark { width: 34px; height: 34px; border-radius: 8px; }
.footer strong { color: var(--text); display: block; }
.footer-link { display: inline-block; margin-top: 4px; color: var(--accent); font-weight: 700; }
.hint a { color: var(--accent); font-weight: 700; }

/* ===== Support ===== */
.support-fab {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: calc(20px + var(--tabbar-h));
  z-index: 35;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 18px 12px 14px;
  border: 1px solid var(--accent-dim); border-radius: 999px;
  background: var(--panel-2); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.support-fab svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .support-fab:hover { background: var(--line); } }
.support-dot { position: absolute; top: -3px; right: -3px; width: 14px; height: 14px; border-radius: 50%; background: var(--danger); border: 2px solid var(--bg); }
/* Room under the footer, so the button never sits on its last line. */
.footer { padding-bottom: 88px; }

.modal-title { margin: 0 0 6px; font-size: 22px; font-weight: 900; }
.support-box .page-sub { margin-bottom: 18px; }
.support-form { display: flex; flex-direction: column; gap: 14px; }
.support-form .btn { align-self: flex-start; }
.support-form .hint { margin: 0; }
.support-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field label .opt { font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--muted-2); }
.support-from, .support-about { margin: 0; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.support-from a { color: var(--accent); font-weight: 700; }
.support-about b { font-family: var(--mono); color: var(--text); }
/* Spam trap: invisible to people, filled in by bots. */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.support-sent { text-align: center; padding: 14px 4px 4px; }
.sent-mark {
  width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(95, 214, 110, 0.12); border: 1px solid var(--accent-dim);
}
.sent-mark svg { width: 28px; height: 28px; fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.support-sent p { color: var(--muted); margin: 0 auto; max-width: 420px; overflow-wrap: anywhere; }
.support-sent-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

.support-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.support-new { max-width: 680px; }
.threads { display: flex; flex-direction: column; gap: 14px; max-width: 780px; }
.thread.unread { border-color: var(--accent-dim); }
.thread-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.thread-topic { font-size: 16px; }
.thread-date { margin-left: auto; color: var(--muted-2); font-size: 13px; }
.thread-about { display: inline-block; margin-bottom: 12px; font-size: 13px; font-weight: 700; color: var(--accent); }
.status-pill {
  font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px;
  background: var(--panel-2); color: var(--silver-2); border: 1px solid var(--line-soft);
}
.status-pill.open { color: var(--accent); border-color: #25502c; }
.status-pill.closed { color: var(--muted); }
.status-pill.new { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.msgs { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 14px; background: var(--well); border: 1px solid var(--line-soft); }
.msg.from-me { align-self: flex-end; background: var(--panel-2); border-bottom-right-radius: 4px; }
.msg.from-admin { align-self: flex-start; border-color: var(--accent-dim); border-bottom-left-radius: 4px; }
.msg-meta { font-size: 12px; font-weight: 700; color: var(--muted-2); margin-bottom: 4px; }
.msg.from-admin .msg-meta { color: var(--accent); }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.thread-reply { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-top: 14px; }
.thread-reply textarea {
  flex: 1; min-width: 0; min-height: 44px; resize: vertical;
  background-color: var(--well); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 16px; outline: none;
}
.thread-reply textarea:focus { border-color: var(--accent-dim); }
.thread-reply .form-error { width: 100%; margin: 0; }
.footer small { margin-left: auto; color: var(--muted-2); max-width: 340px; font-size: 12px; }
.print-head { display: none; }

/* ===== Responsive ===== */
@media (max-width: 980px) {
  .calc-layout { grid-template-columns: 1fr; }
  .calc-result { position: static; }
  .tabs a span, .bookmarks-link span, .account-link.signed-in span { display: none; }
  .tabs a { padding: 9px 12px; }
  .bookmarks-link, .account-link { padding: 8px 10px; }
}

/* Phones held upright (and narrow windows): the app's bottom tab bar, with the raised
   centre Search button. Sideways, the tabs stay in the header, where they take less height. */
@media (max-width: 760px) and (orientation: portrait) {
  :root { --tabbar-h: calc(66px + env(safe-area-inset-bottom)); }
  /* backdrop-filter would make the header the containing block for the fixed tab bar. */
  .topbar { background: var(--bg-2); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .bookmarks-link { margin-left: auto; }

  .tabs {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    margin: 0;
    height: var(--tabbar-h);
    padding: 6px 4px env(safe-area-inset-bottom);
    background: var(--bg-2);
    border-top: 1px solid var(--line-soft);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    z-index: 40;
  }
  .tabs a {
    flex-direction: column;
    gap: 3px;
    padding: 6px 2px 4px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    justify-content: flex-start;
    min-width: 0;
  }
  .tabs a span { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .tabs svg { width: 22px; height: 22px; }
  .tabs a:hover { background: none; }
  .tabs a.active { background: none; color: var(--accent); }
  .tabs .tab-search svg {
    width: 24px; height: 24px; padding: 11px;
    box-sizing: content-box;
    margin: -24px 0 -4px;
    border-radius: 50%;
    background: linear-gradient(180deg, var(--accent-strong), var(--accent));
    stroke: var(--on-accent);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .5);
    border: 4px solid var(--bg-2);
  }
  .tabs a .po-badge {
    position: absolute; top: 0; left: 50%; margin-left: 4px;
    min-width: 0; height: 17px; padding: 0 5px; font-size: 10px;
  }
  /* Above the tab bar, as a round icon button. */
  .support-fab { right: max(14px, env(safe-area-inset-right)); bottom: calc(var(--tabbar-h) + 14px); width: 52px; height: 52px; padding: 0; justify-content: center; }
  .support-fab span { display: none; }
  .support-fab svg { width: 24px; height: 24px; }
}

@media (max-width: 760px) {
  .topbar { gap: 12px; }
  .brand { gap: 9px; }
  .brand-mark { width: 36px; height: 36px; }
  .brand-text strong { font-size: 16px; }
  .brand-text em { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .account-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 22px 18px; }
  .toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar .spacer { display: none; }
  .toolbar select, .toolbar input { width: 100%; }
  .toolbar.makes-toolbar { grid-template-columns: minmax(0, 1fr); }
  .makes-toolbar .segmented { display: flex; }
  .makes-toolbar .segmented button { flex: 1; }
  .fields { grid-template-columns: 1fr; }
  .detail-meta { grid-template-columns: repeat(2, 1fr); }
  .detail-prices .price-box .val { font-size: 26px; }
  .gallery-main { height: 220px; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-card { border-radius: 18px 18px 0 0; max-height: 92vh; max-height: 92dvh; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); }
  .detail-page { padding: 20px 16px; }
  .add-po .btn { margin-left: 0; width: 100%; }
  .po-summary { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .po-summary .stat { padding: 12px 6px; }
  .po-row { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px 12px; }
  .po-row .stepper { grid-column: 2; justify-self: start; }
  .po-row .po-line-total { grid-column: 3; grid-row: 2; }
  .po-row .po-remove { grid-column: 3; grid-row: 1; justify-self: end; }
  .footer small { margin-left: 0; }
  .support-row { grid-template-columns: minmax(0, 1fr); }
  .support-form .btn { align-self: stretch; }
  .msg { max-width: 94%; }
  .thread-date { margin-left: 0; width: 100%; }
}

/* Very narrow phones: "Sign in" shrinks to its icon (screen readers still hear the words),
   and purchase order lines drop the make logo to give the part number room. */
@media (max-width: 360px) {
  .account-link:not(.signed-in) span {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  .po-row { grid-template-columns: minmax(0, 1fr) auto; }
  .po-row > .make-logo { display: none; }
  .po-row .stepper { grid-column: 1; }
  .po-row .po-line-total { grid-column: 2; }
  .po-row .po-remove { grid-column: 2; }
}

/* Touch screens: fingers need bigger targets, and iPhones zoom into form fields whose
   text is under 16px when they're tapped. */
@media (pointer: coarse), (max-width: 760px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select:not([multiple]):not([size]), textarea { font-size: 16px; }
  .bookmarks-link, .account-link { min-height: 40px; min-width: 40px; justify-content: center; }
  .icon-btn { min-height: 40px; }
  .btn.small { min-height: 38px; }
  .segmented button { min-height: 38px; }
  .stepper button { width: 38px; height: 38px; }
  .modal-close { width: 44px; height: 44px; top: 4px; right: 4px; display: flex; align-items: center; justify-content: center; }
  .chip button { min-width: 32px; min-height: 32px; margin: -6px -4px -6px 0; }
  .po-remove { width: 40px; height: 40px; }
  .pager button { min-height: 42px; }
  .link-btn { padding: 10px 6px; }
  .section-head a { display: inline-block; padding: 10px 0; margin: -10px 0; }
  .back-link { padding: 10px 0; margin: -10px 0 6px; }
  .po-info a, .detail-meta .v a { display: inline-block; padding: 6px 0; margin: -6px 0; }
  .suggest a { min-height: 48px; }
  .footer-link { padding: 10px 0; margin: -6px 0 -10px; }
}

/* ===== Print (purchase order) ===== */
@media print {
  :root { --tabbar-h: 0px; }
  body { background: #fff; color: #000; padding: 0; }
  .topbar, .footer, .toast, .modal, .po-list, .po-actions, .page-sub, .no-print, .support-fab { display: none !important; }
  .view { padding: 0; max-width: none; }
  .print-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; border-bottom: 2px solid #000; padding-bottom: 12px; }
  .print-brand { display: flex; align-items: center; gap: 10px; }
  .print-brand img { width: 40px; height: 40px; }
  .print-brand strong { font-size: 20px; font-weight: 900; color: #000; }
  #print-meta { text-align: right; font-size: 12px; }
  .page-title { color: #000; }
  .po-summary .stat { background: none; border: 1px solid #999; }
  .po-summary .stat b, .po-summary .stat span { color: #000; }
  .po-table { display: table; width: 100%; border-collapse: collapse; font-size: 12px; }
  .po-table th, .po-table td { border-bottom: 1px solid #bbb; padding: 7px 6px; text-align: left; }
  .po-table th { text-transform: uppercase; font-size: 10px; letter-spacing: .8px; }
  .po-table td.num, .po-table th.num { text-align: right; }
  .po-table tfoot td { font-weight: 800; border-bottom: none; border-top: 2px solid #000; }
}
