:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1a1d22;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #d4001a;
  --accent-dark: #a30015;
  --jimny-green: #4caf50;
  --boodmo: #12477a;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* CurbOver banner */
.banner {
  background: #000; color: #fff;
  font-size: 13px; letter-spacing: .3px;
  border-bottom: 2px solid var(--accent);
}
.banner .wrap { padding: 8px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.banner > .wrap > span:first-child { flex: 1; text-align: center; }
.banner strong { color: var(--accent); }
.banner .user-strip { font-size: 12px; color: #cbd5e1; white-space: nowrap; }
.banner .user-strip a { color: #fff; text-decoration: underline; }
.banner .user-strip a:hover { color: var(--accent); }

/* topbar */
.topbar { background: #fff; border-bottom: 1px solid var(--line); }
.topbar .wrap {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 20px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.logo-img { width: 56px; height: 56px; border-radius: 8px; display: block; }
.brand-text { display: flex; flex-direction: column; }
.brand-title { font-weight: 800; font-size: 18px; color: var(--ink); letter-spacing: .3px; }
.brand-sub { color: var(--muted); font-size: 12px; }

.search { flex: 1; position: relative; max-width: 600px; margin-left: auto; display: flex; gap: 8px; }
.search input {
  flex: 1; padding: 9px 14px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 6px; background: #fafafa;
}
.search input:focus { outline: 2px solid var(--accent); border-color: var(--accent); background: #fff; }
.search button {
  padding: 9px 18px; font-size: 14px; font-weight: 600;
  background: var(--accent); color: #fff; border: 0; border-radius: 6px;
  cursor: pointer;
}
.search button:hover { background: var(--accent-dark); }

.suggest {
  position: absolute; top: 100%; left: 0; right: 88px;
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  margin: 4px 0 0; padding: 0; list-style: none;
  box-shadow: var(--shadow); display: none; z-index: 50; max-height: 380px; overflow: auto;
}
.suggest.open { display: block; }
.suggest li a {
  display: block; padding: 8px 14px; color: var(--ink); border-bottom: 1px solid var(--line);
}
.suggest li:last-child a { border-bottom: 0; }
.suggest li a:hover { background: #f5f6f8; text-decoration: none; }
.suggest .cat { float: right; color: var(--muted); font-size: 12px; text-transform: uppercase; }

.catnav { background: #1a1d22; }
.catnav .wrap { display: flex; gap: 4px; padding: 0 20px; }
.catnav a {
  padding: 12px 18px; color: #cbd5e1; font-size: 14px; font-weight: 500;
  border-bottom: 3px solid transparent;
}
.catnav a:hover { color: #fff; text-decoration: none; }
.catnav a.active { color: #fff; border-bottom-color: var(--accent); }

/* main */
main.wrap { padding-top: 28px; padding-bottom: 60px; min-height: 60vh; }

h1 { font-size: 28px; margin: 0 0 8px; }
h2 { font-size: 20px; margin: 24px 0 12px; }
.muted { color: var(--muted); }
.crumbs { color: var(--muted); margin-bottom: 18px; font-size: 14px; }
.crumbs a { color: var(--muted); }

/* hero */
.hero { background: linear-gradient(135deg, #1a1d22, #2d3239); color: #fff; padding: 48px 32px; border-radius: 10px; margin-bottom: 28px; }
.hero h1 { font-size: 40px; color: #fff; margin: 0; }
.hero .lede { color: #cbd5e1; margin: 8px 0 0; font-size: 16px; }

/* category grid */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.cat-card {
  background: var(--panel); padding: 24px; border-radius: 10px;
  text-decoration: none; color: var(--ink);
  border: 1px solid var(--line); transition: transform .12s, box-shadow .12s;
  display: flex; flex-direction: column; gap: 4px;
}
.cat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; border-color: var(--accent); }
.cat-card h2 { margin: 0 0 8px; color: var(--accent); font-size: 18px; }
.cat-card p { margin: 0; font-size: 14px; color: var(--muted); }

.hint { margin-top: 32px; padding: 16px 20px; background: #fffaf0; border-left: 3px solid #f0b400; border-radius: 4px; font-size: 14px; }
.hint p { margin: 0; }

/* figure grid */
.fig-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px; margin-top: 16px;
}
.fig-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; text-decoration: none; color: var(--ink);
  display: flex; flex-direction: column;
  transition: transform .12s, box-shadow .12s;
}
.fig-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); text-decoration: none; }
.fig-card .thumb {
  background: #fafafa; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; padding: 12px;
}
.fig-card .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.fig-card .meta { padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.fig-card .fignum { font-size: 11px; font-weight: 700; color: var(--accent); letter-spacing: .5px; }
.fig-card .figname { font-size: 14px; line-height: 1.3; }
.fig-card .pcount { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* figure detail */
.fig-header { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.fig-header h1 { font-size: 22px; }
.fig-header .fignum { display: inline-block; background: var(--accent); color: #fff; padding: 2px 10px; border-radius: 4px; font-size: 14px; margin-right: 8px; }
.fig-nav { display: flex; gap: 8px; }
.fig-nav a {
  padding: 6px 14px; background: #fff; border: 1px solid var(--line); border-radius: 6px;
  color: var(--ink); font-size: 13px;
}
.fig-nav a:hover { background: var(--accent); color: #fff; border-color: var(--accent); text-decoration: none; }

.fig-detail { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 900px) { .fig-detail { grid-template-columns: 1fr; } }
.diagram { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px; position: sticky; top: 20px; }
.diagram img { width: 100%; height: auto; display: block; }
.hint-small { margin: 8px 0 0; font-size: 12px; color: var(--muted); text-align: center; }

.parts { background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.parts table, table.results { width: 100%; border-collapse: collapse; font-size: 14px; }
.parts thead th, table.results thead th {
  background: #fafafa; text-align: left; padding: 10px 12px;
  font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.parts tbody td, table.results tbody td {
  padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top;
}
.parts tbody tr:hover, table.results tbody tr:hover { background: #fafafa; }
.parts tbody tr:target { background: #fff8e1; }
.parts .tag, .parts .qty, .parts .boodmo, table.results .boodmo { width: 1%; white-space: nowrap; }
.parts .boodmo, table.results .boodmo { text-align: right; }
.parts .pn a, table.results .pn a { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 600; color: var(--accent); }
.bubble {
  display: inline-block; background: var(--accent); color: #fff;
  width: 24px; height: 24px; line-height: 24px; text-align: center;
  border-radius: 50%; font-size: 12px; font-weight: 700;
}

/* boodmo CTA */
.boodmo-btn {
  display: inline-block; padding: 5px 12px;
  background: var(--boodmo); color: #fff !important;
  border-radius: 5px; font-size: 12px; font-weight: 600;
  letter-spacing: .3px; white-space: nowrap;
}
.boodmo-btn:hover { background: #0d3a6b; text-decoration: none; }
.boodmo-btn.big { padding: 10px 20px; font-size: 14px; }

.sibling-nav { margin-top: 32px; padding: 16px 20px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.sibling-nav h3 { margin: 0 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.sibling-nav ul { list-style: none; padding: 0; margin: 0; columns: 2; }
@media (max-width: 700px) { .sibling-nav ul { columns: 1; } }
.sibling-nav li { padding: 3px 0; font-size: 13px; }
.sibling-nav li.current a { color: var(--ink); font-weight: 600; }

/* search results */
.filter-bar { display: flex; gap: 8px; margin-bottom: 18px; }
.filter-bar input, .filter-bar select { padding: 8px 12px; font-size: 14px; border: 1px solid var(--line); border-radius: 6px; }
.filter-bar input { flex: 1; }
.filter-bar button { padding: 8px 16px; background: var(--accent); color: #fff; border: 0; border-radius: 6px; font-weight: 600; cursor: pointer; }
table.results { background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.empty { padding: 32px; text-align: center; color: var(--muted); background: #fff; border: 1px dashed var(--line); border-radius: 8px; }

/* part page */
.part-detail { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 24px; }
.part-no-big { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 22px; font-weight: 700; color: var(--accent); margin: 0 0 16px; }
.specs { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; margin: 24px 0; }
.specs dt { color: var(--muted); font-size: 13px; }
.specs dd { margin: 0; }
.appears { list-style: none; padding: 0; }
.appears li { border-bottom: 1px solid var(--line); }
.appears li a { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; gap: 12px; color: var(--ink); }
.appears li a:hover { color: var(--accent); text-decoration: none; }
.appears .cat { padding: 2px 8px; background: #f5f6f8; border-radius: 4px; font-size: 12px; color: var(--muted); }

/* auth pages */
.auth-card {
  max-width: 460px; margin: 40px auto; padding: 32px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 4px; font-size: 24px; }
.auth-card p.muted { margin: 0 0 20px; }
.auth-card form label {
  display: block; margin-bottom: 14px; font-size: 13px; font-weight: 600;
  color: var(--ink);
}
.auth-card form label.check {
  display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 14px;
}
.auth-card form input[type=email],
.auth-card form input[type=text],
.auth-card form input[type=password] {
  display: block; width: 100%; margin-top: 4px;
  padding: 9px 12px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 6px;
  background: #fafafa;
}
.auth-card form input:focus {
  outline: 2px solid var(--accent); border-color: var(--accent); background: #fff;
}
.auth-card form .btn-primary,
.auth-card form input[type=submit] {
  width: 100%; padding: 10px; font-size: 15px; font-weight: 600;
  background: var(--accent); color: #fff;
  border: 0; border-radius: 6px; cursor: pointer; margin-top: 6px;
}
.auth-card form .btn-primary:hover,
.auth-card form input[type=submit]:hover { background: var(--accent-dark); }
.auth-card .alt { margin-top: 20px; text-align: center; font-size: 14px; color: var(--muted); }
.auth-card small.err { display: block; color: var(--accent); font-weight: 400; margin-top: 4px; }
.auth-card small.muted { display: block; color: var(--muted); font-weight: 400; margin-top: 4px; }
.auth-card.pending { text-align: center; }
.auth-card.pending h1 { color: var(--accent); }
.auth-card.pending code { background: #f5f6f8; padding: 2px 6px; border-radius: 4px; font-size: 13px; }

/* flash */
.flash {
  padding: 10px 14px; margin: 0 0 14px; border-radius: 6px;
  font-size: 14px; border-left: 3px solid;
}
.flash-error { background: #fde7ea; border-left-color: var(--accent); color: #7a0010; }
.flash-success { background: #e6f7ec; border-left-color: #1d9b53; color: #0e5b30; }
.flash-info { background: #eaf3fb; border-left-color: var(--boodmo); color: #0d3a6b; }

/* admin users */
.user-section { margin: 28px 0; }
.user-section h2 { display: flex; align-items: center; gap: 10px; }
.user-section .count {
  background: #f5f6f8; color: var(--muted); padding: 2px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 600;
}
table.users { width: 100%; border-collapse: collapse; background: #fff;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
table.users th, table.users td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
table.users thead th { background: #fafafa; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
table.users tr:last-child td { border-bottom: 0; }
table.users td.actions { width: 1%; white-space: nowrap; }
table.users form.inline { display: inline; margin-right: 4px; }
table.users button {
  padding: 6px 12px; font-size: 13px; font-weight: 600;
  border: 0; border-radius: 5px; cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--line) !important; }
.btn-secondary:hover { background: #f5f6f8; }
.btn-danger { background: #6b7280; color: #fff; }
.btn-danger:hover { background: #4b5563; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge.admin { background: var(--accent); color: #fff; }
.badge.status-approved { background: #1d9b53; color: #fff; }
.badge.status-pending  { background: #f0b400; color: #1a1d22; }
.badge.status-rejected { background: #6b7280; color: #fff; }

/* Account page */
.account-card { max-width: 520px; }
.account-card h2 { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 17px; }
.account-info { display: grid; grid-template-columns: 110px 1fr; gap: 6px 14px; margin: 0 0 8px; }
.account-info dt { color: var(--muted); font-size: 13px; align-self: center; }
.account-info dd { margin: 0; font-size: 14px; align-self: center; }

/* footer */
.foot { border-top: 1px solid var(--line); background: #fff; padding: 20px 0; color: var(--muted); font-size: 13px; }
.foot p { margin: 0; }


/* ============================================================
   MOBILE
   ============================================================ */

/* Tablet portrait and below */
@media (max-width: 760px) {
  .wrap { padding: 0 14px; }
  main.wrap { padding-top: 18px; padding-bottom: 36px; }

  /* Banner — stack tagline above user strip */
  .banner .wrap { padding: 6px 14px; gap: 2px; flex-direction: column; align-items: center; }
  .banner > .wrap > span { flex: none; min-width: 0; max-width: 100%; text-align: center; line-height: 1.35; }
  .banner > .wrap > span:first-child { font-size: 12px; }
  .banner .user-strip { font-size: 11px; white-space: normal; }

  /* Topbar — brand + auth row, then search full-width */
  .topbar .wrap { gap: 10px; padding: 10px 14px; flex-wrap: wrap; }
  .brand { gap: 10px; }
  .logo-img { width: 40px; height: 40px; }
  .brand-title { font-size: 15px; }
  .brand-sub { font-size: 11px; }
  .search { order: 10; flex-basis: 100%; max-width: none; margin-left: 0; }
  .search input { font-size: 16px; padding: 10px 12px; }    /* 16px avoids iOS zoom-on-focus */
  .search button { padding: 10px 16px; font-size: 14px; }
  .suggest { right: 0; }

  /* Catnav — horizontal scroll */
  .catnav .wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 14px;
    flex-wrap: nowrap;
  }
  .catnav .wrap::-webkit-scrollbar { display: none; }
  .catnav a { padding: 11px 14px; font-size: 13px; flex-shrink: 0; }

  /* Crumbs + headings */
  .crumbs { font-size: 13px; margin-bottom: 14px; }
  h1 { font-size: 22px; }
  h2 { font-size: 17px; }

  /* Hero */
  .hero { padding: 28px 20px; border-radius: 8px; margin-bottom: 18px; }
  .hero h1 { font-size: 26px; }
  .hero .lede { font-size: 14px; }

  /* Category cards — 2 per row */
  .cat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .cat-card { padding: 16px; }
  .cat-card h2 { font-size: 15px; margin-bottom: 4px; }
  .cat-card p { font-size: 13px; }
  .hint { padding: 12px 14px; font-size: 13px; margin-top: 22px; }

  /* Figure grid — 2 per row */
  .fig-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .fig-card .meta { padding: 8px 10px; }
  .fig-card .figname { font-size: 13px; }

  /* Figure detail */
  .fig-header { flex-direction: column; align-items: stretch; gap: 8px; }
  .fig-header h1 { font-size: 18px; }
  .fig-header .fignum { padding: 1px 8px; font-size: 13px; }
  .fig-nav { flex-wrap: wrap; }
  .fig-nav a { padding: 7px 12px; font-size: 12px; }
  .fig-detail { gap: 14px; grid-template-columns: 1fr; }
  .diagram { position: static; padding: 10px; }

  /* Parts table → card-style rows */
  .parts { border-radius: 6px; }
  .parts table { display: block; }
  .parts thead { display: none; }
  .parts tbody, .parts tr { display: block; }
  .parts td { display: block; padding: 0; border: 0; white-space: normal; }
  .parts tr {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto;
    grid-template-areas:
      "tag pn   action"
      "tag name name"
      "tag qty  qty";
    column-gap: 10px; row-gap: 4px;
    padding: 12px 14px; border-bottom: 1px solid var(--line);
  }
  .parts tr:last-child { border-bottom: 0; }
  .parts td.tag { grid-area: tag; align-self: start; padding-top: 2px; width: auto; }
  .parts td.pn { grid-area: pn; }
  .parts td.pn a { font-size: 14px; }
  .parts td.boodmo { grid-area: action; text-align: right; width: auto; }
  /* The "name" cell is the unnamed (3rd) td */
  .parts td:nth-child(3) { grid-area: name; font-size: 13px; color: var(--ink); line-height: 1.35; }
  .parts td:nth-child(3) small { font-size: 12px; }
  .parts td.qty { grid-area: qty; font-size: 12px; color: var(--muted); width: auto; }
  .parts td.qty:not(:empty)::before { content: "Qty "; }
  .parts td.qty:empty { display: none; }

  /* Search results table → card rows */
  table.results { display: block; }
  table.results thead { display: none; }
  table.results tbody, table.results tr { display: block; }
  table.results td { display: block; padding: 0; border: 0; }
  table.results tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "pn     action"
      "name   name"
      "cat    fig";
    column-gap: 10px; row-gap: 4px;
    padding: 12px 14px; border-bottom: 1px solid var(--line);
  }
  table.results tr:last-child { border-bottom: 0; }
  table.results td.pn { grid-area: pn; }
  table.results td:nth-child(2) { grid-area: name; font-size: 13px; line-height: 1.35; }
  table.results td:nth-child(3) { grid-area: cat; font-size: 12px; }
  table.results td:nth-child(4) { grid-area: fig; font-size: 12px; text-align: right; color: var(--muted); }
  table.results td.boodmo { grid-area: action; text-align: right; width: auto; }

  /* Filter bar wraps cleanly */
  .filter-bar { flex-wrap: wrap; gap: 6px; }
  .filter-bar input { flex-basis: 100%; }
  .filter-bar select { flex: 1; }
  .filter-bar button { flex-shrink: 0; }

  /* Sibling nav — single column already at 700px; reduce padding */
  .sibling-nav { padding: 12px 14px; margin-top: 22px; }

  /* Boodmo button — bigger touch target */
  .boodmo-btn { padding: 8px 14px; font-size: 13px; min-height: 36px; line-height: 1.2; display: inline-flex; align-items: center; }
  .boodmo-btn.big { padding: 12px 20px; font-size: 14px; }

  /* Auth pages */
  .auth-card { margin: 16px auto; padding: 22px; }
  .auth-card h1 { font-size: 22px; }
  .auth-card form input[type=email],
  .auth-card form input[type=text],
  .auth-card form input[type=password] { font-size: 16px; padding: 10px 12px; }    /* iOS no-zoom */
  .auth-card form .btn-primary,
  .auth-card form input[type=submit] { padding: 12px; font-size: 16px; }

  /* Account page info */
  .account-info { grid-template-columns: 90px 1fr; gap: 4px 12px; }
  .account-info dt { font-size: 12px; }
  .account-info dd { font-size: 13px; }

  /* Admin users → stacked cards */
  table.users { display: block; border: 0; background: transparent; }
  table.users thead { display: none; }
  table.users tbody, table.users tr { display: block; }
  table.users td { display: block; padding: 0; border: 0; }
  table.users tr {
    background: #fff;
    border: 1px solid var(--line); border-radius: 8px;
    padding: 14px; margin-bottom: 10px;
    display: grid; gap: 4px;
  }
  table.users td:nth-child(1) { font-size: 15px; font-weight: 600; }
  table.users td:nth-child(2) { font-size: 13px; word-break: break-all; }
  table.users td:nth-child(2) code { background: #f5f6f8; padding: 2px 6px; border-radius: 3px; font-size: 12px; }
  table.users td:nth-child(3),
  table.users td:nth-child(4) { font-size: 12px; color: var(--muted); }
  table.users td.actions { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; width: auto; }
  table.users td.actions form.inline { margin: 0; flex: 1 1 auto; }
  table.users td.actions button { width: 100%; padding: 10px 14px; font-size: 14px; }

  /* Flash messages */
  .flash { font-size: 13px; padding: 10px 12px; }
}

/* Small phones — fine-tune density */
@media (max-width: 420px) {
  .cat-grid { grid-template-columns: 1fr; }
  .fig-grid { grid-template-columns: 1fr 1fr; }
  .hero { padding: 24px 18px; }
  .hero h1 { font-size: 22px; }
  .brand-title { font-size: 14px; }
  .brand-sub { display: none; }
  .logo-img { width: 36px; height: 36px; }
  .banner > .wrap > span:first-child { font-size: 11px; }
}
