/* CAD marketplace — Phase 1 stylesheet. No framework, no build step. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #14181d;
  --ink-soft: #5b6672;
  --line: #dde1e6;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --ok: #116b3f;
  --warn-bg: #fff6e5;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 24, 29, .06), 0 4px 12px rgba(20, 24, 29, .04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */
.site-header {
  background: var(--ink);
  color: #fff;
  padding: 14px 0;
  margin-bottom: 28px;
}
.site-header .wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 650; font-size: 17px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; opacity: .85; }
.site-nav { margin-left: auto; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.site-nav a { color: #c9d2dc; font-size: 14px; }
.site-nav a:hover { color: #fff; }
.site-nav .who { color: #7d8b99; font-size: 13px; }
.site-nav form { margin: 0; }
.linkish {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: #c9d2dc; font: inherit; font-size: 14px;
}
.linkish:hover { color: #fff; text-decoration: underline; }

/* ---------- generic ---------- */
h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.02em; }
h2 { font-size: 18px; margin: 0 0 12px; letter-spacing: -.01em; }
.lede { color: var(--ink-soft); margin: 0 0 22px; }
.muted { color: var(--ink-soft); }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.btn {
  display: inline-block; cursor: pointer;
  padding: 9px 16px; border-radius: 6px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 550; font-size: 14px; text-align: center;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: var(--line); }
.btn.block { display: block; width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.flash { padding: 11px 14px; border-radius: 6px; margin-bottom: 18px; font-size: 14px; }
.flash.ok    { background: #e7f6ed; color: var(--ok); border: 1px solid #b7e0c8; }
.flash.error { background: #fdecea; color: var(--danger); border: 1px solid #f3c1bb; }
.errors { margin: 0 0 18px; padding: 12px 14px 12px 32px; }
.errors li { margin: 2px 0; }

/* ---------- forms ---------- */
.form-card { padding: 24px; }
.narrow { max-width: 460px; margin: 0 auto; }
.field { margin-bottom: 18px; }
.field > label, .field-label {
  display: block; font-weight: 550; font-size: 13px; margin-bottom: 6px;
}
.field .hint { display: block; color: var(--ink-soft); font-size: 12.5px; margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search],
select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; font-size: 14px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(31, 111, 235, .35); outline-offset: -1px; border-color: var(--accent);
}
textarea { min-height: 120px; resize: vertical; }
input[type=file] { font-size: 13px; }
.req { color: var(--danger); }
.checkbox-row { display: flex; gap: 9px; align-items: flex-start; font-size: 14px; }
.checkbox-row input { margin-top: 3px; flex: none; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.declaration { background: var(--warn-bg); border: 1px solid #f0dcb4; border-radius: 6px; padding: 14px; }
fieldset { border: 0; padding: 0; margin: 0 0 22px; }
fieldset legend {
  padding: 0; font-size: 12px; font-weight: 650; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-soft); margin-bottom: 14px;
}
.fitment-row { display: grid; grid-template-columns: 1.2fr 1.2fr .7fr .7fr; gap: 10px; margin-bottom: 10px; }

/* ---------- browse ---------- */
.browse { display: grid; grid-template-columns: 232px 1fr; gap: 26px; align-items: start; }
.filters { padding: 18px; position: sticky; top: 18px; }
.filters h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.filters .field { margin-bottom: 15px; }
.results-head {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 16px;
}
.results-head .count { color: var(--ink-soft); font-size: 14px; margin-left: auto; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 18px; }
.tile { overflow: hidden; display: flex; flex-direction: column; }
.tile:hover { border-color: #c3cbd4; }
.tile .thumb {
  display: block; aspect-ratio: 4 / 3; background: #e9edf1;
  border-bottom: 1px solid var(--line); overflow: hidden;
}
.tile .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.tile .title { font-weight: 600; font-size: 14.5px; color: var(--ink); line-height: 1.35; }
.tile .title:hover { color: var(--accent); text-decoration: none; }
.tile .meta { color: var(--ink-soft); font-size: 12.5px; margin-top: auto; }

.tags { display: flex; gap: 5px; flex-wrap: wrap; }
.tag {
  font-size: 11px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 4px; background: #eef1f5; color: var(--ink-soft);
  border: 1px solid var(--line);
}
.tag.fmt { background: #eaf1fd; color: #1a4fa8; border-color: #cddffa; }
.tag.ready { background: #e7f6ed; color: var(--ok); border-color: #b7e0c8; }

.empty { padding: 46px 24px; text-align: center; color: var(--ink-soft); }

/* ---------- detail ---------- */
.detail { display: grid; grid-template-columns: 1.35fr 1fr; gap: 26px; align-items: start; }
.detail .shot { overflow: hidden; }
.detail .shot img { width: 100%; display: block; background: #e9edf1; }
.side { padding: 20px; margin-bottom: 18px; }
.side h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.spec { width: 100%; border-collapse: collapse; font-size: 14px; }
.spec th, .spec td { text-align: left; padding: 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.spec th { font-weight: 550; color: var(--ink-soft); width: 44%; font-size: 13px; }
.spec tr:last-child th, .spec tr:last-child td { border-bottom: 0; }
.filelist { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.filelist li {
  display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line);
}
.filelist li:last-child { border-bottom: 0; }
.filelist .name { word-break: break-all; }
.filelist .size { margin-left: auto; color: var(--ink-soft); font-size: 13px; white-space: nowrap; }
.prose { white-space: pre-wrap; margin: 0; }

/* ---------- tables (admin, my models) ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--surface); }
.table th, .table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.table tr:last-child td { border-bottom: 0; }
.table-card { overflow: hidden; padding: 0; }

.pager { display: flex; gap: 10px; justify-content: center; margin: 26px 0 8px; align-items: center; }

footer.site-footer {
  margin-top: 48px; padding: 22px 0; border-top: 1px solid var(--line);
  color: var(--ink-soft); font-size: 13px;
}

@media (max-width: 860px) {
  .browse, .detail { grid-template-columns: 1fr; }
  .filters { position: static; }
  .grid-2, .fitment-row { grid-template-columns: 1fr; }
}

[hidden] { display: none !important; }

/* ---------- Phase 2: earnings ---------- */

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
/* Proportional figures: tabular-nums makes a standalone number look loose. */
.stat-figure { font-size: 30px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; }
.stat-note { font-size: 12.5px; color: var(--ink-soft); }

.chart-card, .table-card { padding: 18px; margin-bottom: 18px; }
.chart-sub { font-size: 13px; margin: -6px 0 16px; }

/* The plot box grows with its content so the x-axis band is never clipped. */
.plot { display: flex; gap: 10px; height: 170px; }
.y-axis {
  display: flex; flex-direction: column; justify-content: space-between;
  font-size: 11px; color: var(--ink-soft); font-variant-numeric: tabular-nums;
  text-align: right; min-width: 24px; padding-bottom: 1px;
}
/* Solid hairline baseline, one shade off the surface — never dashed. */
.bars { flex: 1; display: flex; align-items: flex-end; gap: 2px; border-bottom: 1px solid var(--line); }
.bar-slot { flex: 1; height: 100%; display: flex; align-items: flex-end; max-width: 24px; }
.bar {
  width: 100%; background: var(--accent);
  /* 4px rounded data-end, square where it meets the baseline. */
  border-radius: 4px 4px 0 0;
  min-height: 0;
}
.bar-slot:hover .bar { background: #1a5fd0; }
.x-axis {
  display: flex; justify-content: space-between;
  font-size: 11.5px; color: var(--ink-soft); margin-top: 8px; padding-left: 34px;
}

.table-view { margin-top: 16px; }
.table-view summary { font-size: 13px; color: var(--ink-soft); cursor: pointer; }
.table-view summary:hover { color: var(--ink); }
.table.compact td, .table.compact th { padding: 6px 10px; font-size: 13px; }

/* tabular-nums where numbers stack vertically and must align. */
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .num.strong { font-weight: 600; }
.table .num.shortfall { color: var(--ink-soft); }
.tag.warn { background: var(--warn-bg); color: #8a5a00; border: 1px solid #f0dcb4; }

.admin-note { font-size: 13px; color: var(--ink-soft); margin: -6px 0 14px; }
.void-form { display: grid; gap: 12px; max-width: 520px; }
.cluster-bar { display: inline-block; height: 6px; border-radius: 3px; background: var(--accent); vertical-align: middle; }
.filter-inline { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filter-inline label { font-size: 12.5px; color: var(--ink-soft); display: flex; flex-direction: column; gap: 4px; }
.filter-inline input { width: 110px; }
.inline-void { margin: 0; }

/* ---------- spending: featured placement ---------- */
.spend-card { padding: 18px; margin-bottom: 18px; }
.spend-table td { vertical-align: middle; }
.spend-table th.buy, .spend-table td.buy { text-align: right; white-space: nowrap; }
.buy-form { display: inline-flex; gap: 8px; align-items: center; margin: 0; }
.buy-form select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.buy-form button[disabled] { opacity: .5; cursor: not-allowed; }
.spend-short { margin: 12px 0 0; font-size: 13px; }
.tag.live { background: #e7f0fe; color: #14458f; border: 1px solid #c5d9fb; }
.tag.queued { background: #eef0f3; color: var(--ink-soft); border: 1px solid var(--line); }
.tile .tag.live { font-weight: 600; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- wallet linking ---------- */
.wallet-card { padding: 18px; margin-bottom: 18px; }
.wallet-address { margin: 0 0 6px; }
.wallet-address code, .wallet-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px; word-break: break-all;
}
.wallet-address code { font-size: 15px; }
.wallet-actions { margin: 14px 0 0; }
.wallet-status { min-height: 1.4em; margin: 10px 0 0; font-size: 13.5px; color: var(--ink-soft); }
.wallet-status.error { color: var(--danger); }
.wallet-note { font-size: 13px; margin: 14px 0 0; }
#wallet-connect[disabled] { opacity: .5; cursor: not-allowed; }
