/* avas.parts — parts-catalogue interface
   Light skin  = customer browse ("catalogue paper")
   Dark skin   = staff counter ("terminal"), so cost prices can never be
                 mistaken for a customer-facing screen. */

:root {
  --ground:  #E9EAE4;
  --panel:   #F7F7F3;
  --panel-2: #FFFFFF;
  --ink:     #14181A;
  --ink-2:   #5C645F;
  --ink-3:   #8A918C;
  --rule:    #C6CAC2;
  --rule-2:  #DCDFD8;
  --hot:     #C8102E;
  --hot-ink: #FFFFFF;
  --sea:     #0B5D66;
  --amber:   #96650F;
  --ok:      #2E6B3E;

  --r: 3px;
  --shadow: 0 1px 0 rgba(20,24,26,.06), 0 8px 24px -12px rgba(20,24,26,.28);

  --f-disp: "IBM Plex Sans Condensed", "Arial Narrow", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --f-dv:   "Noto Sans Thaana", var(--f-body);
}

[data-skin="staff"] {
  --ground:  #0D1315;
  --panel:   #151D20;
  --panel-2: #1B2529;
  --ink:     #E2E8E6;
  --ink-2:   #93A09D;
  --ink-3:   #6B7875;
  --rule:    #2B3639;
  --rule-2:  #222D30;
  --hot:     #FF5252;
  --hot-ink: #14181A;
  --sea:     #45D6CE;
  --amber:   #E8A33D;
  --ok:      #5FCB7E;
  --shadow: 0 1px 0 rgba(0,0,0,.4), 0 14px 34px -14px rgba(0,0,0,.7);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.5;
  transition: background .25s ease, color .25s ease;
}

:focus-visible {
  outline: 2px solid var(--hot);
  outline-offset: 2px;
}

button { font: inherit; color: inherit; cursor: pointer; }

.dv { font-family: var(--f-dv); direction: rtl; unicode-bidi: isolate; }

/* ============ COMMAND BAR ============ */
.bar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 10px clamp(12px, 3vw, 28px);
  background: var(--panel);
  border-bottom: 1px solid var(--rule);
}

.logo {
  display: flex; align-items: baseline; gap: 2px;
  font-family: var(--f-disp);
  font-weight: 700; font-size: 21px; letter-spacing: -.02em;
  text-decoration: none; color: var(--ink);
  white-space: nowrap;
}
.logo b { color: var(--hot); font-weight: 700; }
.logo .dot { color: var(--ink-3); font-weight: 400; }

.searchwrap { position: relative; flex: 1; min-width: 0; max-width: 620px; }

.search {
  width: 100%;
  padding: 9px 12px 9px 34px;
  font-family: var(--f-mono); font-size: 13.5px;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--rule);
  border-radius: var(--r);
}
.search::placeholder { color: var(--ink-3); }
.search:focus { border-color: var(--hot); outline: none; }

.searchwrap::before {
  content: "▸"; position: absolute; left: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--hot); font-size: 12px; pointer-events: none;
}

.barspacer { flex: 1; }

.mode {
  display: flex; border: 1px solid var(--rule); border-radius: var(--r);
  overflow: hidden; background: var(--panel-2); flex-shrink: 0;
}
.mode button {
  border: 0; background: transparent;
  padding: 7px 11px;
  font-family: var(--f-disp); font-size: 12px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-2);
}
.mode button[aria-pressed="true"] { background: var(--ink); color: var(--ground); }

.cartbtn {
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--panel-2); padding: 7px 12px;
  font-family: var(--f-disp); font-size: 12px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  flex-shrink: 0;
}
.cartbtn:hover { border-color: var(--hot); }
.cartbtn .n {
  min-width: 19px; height: 19px; padding: 0 5px;
  display: grid; place-items: center;
  background: var(--hot); color: var(--hot-ink);
  border-radius: 999px;
  font-family: var(--f-mono); font-size: 11px; font-weight: 600;
}
.cartbtn .n[data-empty="1"] { background: var(--rule); color: var(--ink-2); }

/* ============ SHELL ============ */
.shell { max-width: 1360px; margin: 0 auto; padding: 0 clamp(12px, 3vw, 28px); }

/* ============ HERO — the finder is the hero ============ */
.hero { padding: 28px 0 18px; }

/* At the counter the pitch is dead weight — go straight to the pickers. */
[data-skin="staff"] .hero { padding: 16px 0 12px; }
[data-skin="staff"] .hero h1,
[data-skin="staff"] .hero .lede { display: none; }

.kicker {
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-3);
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.kicker::after { content:""; flex:1; height:1px; background: var(--rule); }

.hero h1 {
  font-family: var(--f-disp);
  font-size: clamp(30px, 5.2vw, 54px);
  line-height: .98; letter-spacing: -.025em;
  font-weight: 700; margin: 0 0 8px;
  text-transform: uppercase;
}
.hero h1 em { font-style: normal; color: var(--hot); }

.hero p.lede {
  margin: 0 0 22px; max-width: 54ch;
  color: var(--ink-2); font-size: 15.5px;
}

/* Brand + model pickers */
.pickrow { margin-bottom: 14px; }
.picklabel {
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 7px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  border: 1px solid var(--rule); background: var(--panel);
  border-radius: var(--r); padding: 6px 11px;
  font-family: var(--f-disp); font-size: 13.5px; font-weight: 500;
  color: var(--ink); white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.chip:hover { border-color: var(--ink-2); }
.chip[aria-pressed="true"] {
  background: var(--ink); color: var(--ground); border-color: var(--ink);
}
.chip .cc {
  font-family: var(--f-mono); font-size: 10.5px;
  color: var(--ink-3); margin-left: 5px;
}
.chip[aria-pressed="true"] .cc { color: var(--ground); opacity: .65; }

.chip.hotpick { border-color: var(--hot); }
.chip.hotpick::before {
  content:"●"; color: var(--hot); font-size: 8px;
  vertical-align: middle; margin-right: 5px;
}
.chip.hotpick[aria-pressed="true"]::before { color: var(--ground); }

/* ============ RESULTS LAYOUT ============ */
.work { display: grid; grid-template-columns: 208px 1fr; gap: 24px; padding-bottom: 60px; }
/* grid children default to min-width:auto, which lets the scrolling category
   rail push the whole page wide on narrow screens */
.work > * { min-width: 0; }

.rail { position: sticky; top: 68px; align-self: start; }

.railhead {
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-3);
  padding-bottom: 8px; border-bottom: 1px solid var(--rule); margin-bottom: 6px;
}

.catbtn {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  width: 100%; text-align: left;
  border: 0; background: transparent;
  padding: 6px 8px; border-radius: var(--r);
  font-size: 14px; color: var(--ink-2);
  border-left: 2px solid transparent;
}
.catbtn:hover { background: var(--panel); color: var(--ink); }
.catbtn[aria-pressed="true"] {
  background: var(--panel); color: var(--ink);
  border-left-color: var(--hot); font-weight: 600;
}
.catbtn .k { font-family: var(--f-mono); font-size: 11px; color: var(--ink-3); }

/* ============ RESULT HEADER ============ */
.rhead {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  padding-bottom: 10px; margin-bottom: 14px;
  border-bottom: 2px solid var(--ink);
}
.rhead h2 {
  font-family: var(--f-disp); font-size: 22px; font-weight: 700;
  letter-spacing: -.01em; margin: 0; text-transform: uppercase;
}
.rhead .count { font-family: var(--f-mono); font-size: 12px; color: var(--ink-2); }

.clearbtn {
  border: 1px solid var(--rule); background: transparent;
  border-radius: var(--r); padding: 4px 9px;
  font-family: var(--f-mono); font-size: 11px; color: var(--ink-2);
}
.clearbtn:hover { border-color: var(--hot); color: var(--hot); }

/* ============ PART CARD ============ */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 12px; }

.card {
  background: var(--panel); border: 1px solid var(--rule);
  border-radius: var(--r); padding: 13px 14px 12px;
  display: flex; flex-direction: column; gap: 9px;
  transition: border-color .14s, transform .14s;
}
.card:hover { border-color: var(--ink-2); }

/* Schematic drawing, or the shop's own photo once data.js has an `img`.
   Drawn in the register of a printed parts catalogue, not a product shot. */
.art {
  display: grid; place-items: center;
  height: 108px; margin: -3px -4px 2px;
  background:
    repeating-linear-gradient(var(--panel-2) 0 21px, var(--rule-2) 21px 22px),
    var(--panel-2);
  border: 1px solid var(--rule-2); border-radius: 2px;
  overflow: hidden;
}
.art svg { width: 100%; height: 100%; padding: 6px 0; }
.art svg :is(path, rect, circle, ellipse) {
  fill: none; stroke: var(--ink-2);
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.art svg .f { stroke: var(--hot); }

/* Photo covers the drawing. If the image fails, onerror removes the class
   and the drawing underneath shows through. */
.art { position: relative; }
.art img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover; display: block;
  background: var(--panel-2);
}
.art.has-photo { background: var(--panel-2); }
.art.has-photo svg { visibility: hidden; }
.card:hover .art svg :is(path, rect, circle, ellipse) { stroke: var(--ink); }
.card:hover .art svg .f { stroke: var(--hot); }

.cardtop { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }

.cardname {
  font-family: var(--f-disp); font-size: 16.5px; font-weight: 600;
  line-height: 1.18; margin: 0; letter-spacing: -.005em;
}

.tier {
  font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .1em;
  text-transform: uppercase; padding: 2px 6px; border-radius: 2px;
  border: 1px solid currentColor; white-space: nowrap; flex-shrink: 0;
}
.tier.genuine    { color: var(--hot); }
.tier.oem-alt    { color: var(--sea); }
.tier.aftermarket{ color: var(--ink-3); }

/* --- SIGNATURE: the segmented part-number plate --- */
.plate {
  display: inline-flex; align-items: stretch;
  border: 1px solid var(--rule); border-radius: 2px;
  background: var(--panel-2); overflow: hidden; align-self: flex-start;
  max-width: 100%;
}
.seg { padding: 4px 8px 3px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.seg + .seg { border-left: 1px solid var(--rule-2); }
.seg .val {
  font-family: var(--f-mono); font-size: 14px; font-weight: 600;
  letter-spacing: .02em; line-height: 1.1; white-space: nowrap;
}
.seg .lab {
  font-family: var(--f-mono); font-size: 8px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-3); line-height: 1;
}
.seg.g .val { color: var(--ink); }
.seg.f .val { color: var(--hot); }
.seg.r .val { color: var(--ink-2); }
.plate.plain .seg .val { color: var(--ink); }

.decode {
  font-size: 12px; color: var(--ink-2); line-height: 1.4;
}
.decode b { color: var(--ink); font-weight: 600; }

.unver {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--amber);
}
.unver::before { content: "▲"; font-size: 8px; }

/* fitment ribbon */
.ribbon { display: flex; flex-wrap: wrap; gap: 4px; }
.fitchip {
  font-family: var(--f-mono); font-size: 10.5px;
  padding: 2px 6px; border-radius: 2px;
  background: var(--rule-2); color: var(--ink-2);
  white-space: nowrap;
}
.fitchip.on { background: var(--hot); color: var(--hot-ink); font-weight: 600; }
.fitchip.uni { background: transparent; border: 1px dashed var(--rule); color: var(--ink-3); }

.cardfoot {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 10px; margin-top: auto; padding-top: 9px;
  border-top: 1px solid var(--rule-2);
}

.price { display: flex; flex-direction: column; line-height: 1.05; }
.price .cur { font-family: var(--f-mono); font-size: 10px; color: var(--ink-3); letter-spacing: .1em; }
.price .amt { font-family: var(--f-disp); font-size: 23px; font-weight: 700; letter-spacing: -.02em; }

.addbtn {
  border: 1px solid var(--ink); background: var(--ink); color: var(--ground);
  border-radius: var(--r); padding: 7px 13px;
  font-family: var(--f-disp); font-size: 13px; font-weight: 600;
  letter-spacing: .03em; white-space: nowrap;
}
.addbtn:hover { background: var(--hot); border-color: var(--hot); color: var(--hot-ink); }
.addbtn:disabled { background: transparent; color: var(--ink-3); border-color: var(--rule); cursor: not-allowed; }

.moreb {
  border: 0; background: transparent; padding: 0;
  font-family: var(--f-mono); font-size: 11px; color: var(--sea);
  text-decoration: underline; text-underline-offset: 3px; text-align: left;
}

/* staff-only block */
.staffbox {
  display: none;
  border: 1px dashed var(--rule); border-radius: 2px;
  padding: 7px 9px; gap: 4px 14px;
  font-family: var(--f-mono); font-size: 11px;
  grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
}
[data-skin="staff"] .staffbox { display: grid; }
.staffbox div { display: flex; flex-direction: column; }
.staffbox .l { color: var(--ink-3); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.staffbox .v { color: var(--ink); }
.staffbox .v.low { color: var(--hot); font-weight: 600; }
.staffbox .v.marg { color: var(--ok); }

.stockline { font-family: var(--f-mono); font-size: 11px; color: var(--ink-2); }
.stockline .dotg { color: var(--ok); }
.stockline .doty { color: var(--amber); }
.stockline .dotr { color: var(--hot); }

/* ============ EMPTY ============ */
.empty {
  border: 1px dashed var(--rule); border-radius: var(--r);
  padding: 40px 24px; text-align: center; color: var(--ink-2);
}
.empty h3 { font-family: var(--f-disp); font-size: 19px; margin: 0 0 6px; color: var(--ink); }
.empty p { margin: 0 0 14px; font-size: 14px; }

/* ============ DRAWER (cart + detail) ============ */
.scrim {
  position: fixed; inset: 0; background: rgba(10,14,16,.5);
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 90;
}
.scrim.on { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(430px, 100%);
  background: var(--panel); border-left: 1px solid var(--rule);
  z-index: 100; transform: translateX(100%);
  transition: transform .26s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.drawer.on { transform: none; }

.dhead {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--rule); flex-shrink: 0;
}
.dhead h3 {
  font-family: var(--f-disp); font-size: 17px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .02em; margin: 0;
}
.xbtn { border: 0; background: transparent; font-size: 21px; line-height: 1; color: var(--ink-2); padding: 0 4px; }
.xbtn:hover { color: var(--hot); }

.dbody { overflow-y: auto; padding: 16px; flex: 1; }
.dfoot { border-top: 1px solid var(--rule); padding: 14px 16px; flex-shrink: 0; background: var(--panel-2); }

/* cart lines */
.line { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--rule-2); }
.line:last-child { border-bottom: 0; }
.line .info { flex: 1; min-width: 0; }
.line .nm { font-family: var(--f-disp); font-size: 14.5px; font-weight: 600; line-height: 1.2; }
.line .pn { font-family: var(--f-mono); font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.line .rt { text-align: right; }
.line .lp { font-family: var(--f-mono); font-size: 13px; }

.qty { display: inline-flex; border: 1px solid var(--rule); border-radius: 2px; margin-top: 5px; }
.qty button { border: 0; background: transparent; width: 24px; height: 22px; font-size: 14px; line-height: 1; color: var(--ink-2); }
.qty button:hover { color: var(--hot); }
.qty span { min-width: 26px; display: grid; place-items: center; font-family: var(--f-mono); font-size: 12px; border-left: 1px solid var(--rule); border-right: 1px solid var(--rule); }

/* form */
.field { margin-bottom: 11px; }
.field label {
  display: block; font-family: var(--f-mono); font-size: 10px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px; font-family: var(--f-body); font-size: 14px;
  color: var(--ink); background: var(--panel-2);
  border: 1px solid var(--rule); border-radius: var(--r);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--hot); outline: none; }
.field textarea { resize: vertical; min-height: 56px; }
.hint { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }

.totals { font-family: var(--f-mono); font-size: 13px; margin-bottom: 11px; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .grand {
  border-top: 1px solid var(--rule); margin-top: 5px; padding-top: 7px;
  font-size: 17px; font-weight: 600;
}
.totals .grand span:last-child { color: var(--hot); }

.gobtn {
  width: 100%; border: 0; border-radius: var(--r);
  background: var(--hot); color: var(--hot-ink);
  padding: 12px; font-family: var(--f-disp); font-size: 15px;
  font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
.gobtn:hover { filter: brightness(1.08); }
.gobtn:disabled { background: var(--rule); color: var(--ink-3); cursor: not-allowed; }

/* detail drawer bits */
.dsec { margin-bottom: 18px; }
.dsec h4 {
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-3);
  margin: 0 0 7px; padding-bottom: 5px; border-bottom: 1px solid var(--rule-2);
}
.altlist { display: flex; flex-direction: column; gap: 5px; }
.altrow {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--f-mono); font-size: 12.5px;
  padding: 5px 8px; background: var(--panel-2);
  border: 1px solid var(--rule-2); border-radius: 2px;
}
.altrow .tag {
  font-size: 9px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); margin-left: auto; white-space: nowrap;
}
.fitfull { display: flex; flex-wrap: wrap; gap: 5px; }
.fitfull .m {
  font-size: 12px; padding: 3px 8px; border-radius: 2px;
  background: var(--panel-2); border: 1px solid var(--rule-2);
}
.fitfull .m b { font-weight: 600; }
.notebox {
  border-left: 2px solid var(--sea); padding: 6px 0 6px 10px;
  font-size: 13.5px; color: var(--ink-2);
}

/* ============ FOOTER ============ */
.foot {
  border-top: 1px solid var(--rule); background: var(--panel);
  padding: 30px clamp(12px,3vw,28px) 40px; margin-top: 20px;
}
.footin { max-width: 1360px; margin: 0 auto; display: grid; gap: 26px; grid-template-columns: repeat(auto-fit, minmax(210px,1fr)); }
.foot h5 {
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-3); margin: 0 0 8px;
}
.foot p, .foot li { font-size: 13.5px; color: var(--ink-2); margin: 0 0 5px; }
.foot ul { list-style: none; padding: 0; margin: 0; }
.foot a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule); }
.foot a:hover { color: var(--hot); border-color: var(--hot); }
.zline { display: flex; justify-content: space-between; gap: 10px; font-family: var(--f-mono); font-size: 12px; }
.zline span:last-child { color: var(--ink-3); white-space: nowrap; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--ground);
  padding: 10px 18px; border-radius: var(--r);
  font-family: var(--f-disp); font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 200;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ============ RESPONSIVE ============ */
@media (max-width: 880px) {
  .work { grid-template-columns: 1fr; }
  .rail { position: static; }
  .rail .catwrap { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 6px; }
  .catbtn { width: auto; white-space: nowrap; border-left: 0; border-bottom: 2px solid transparent; }
  .catbtn[aria-pressed="true"] { border-left: 0; border-bottom-color: var(--hot); }
  .catbtn .k { display: none; }
}
@media (max-width: 640px) {
  .bar { flex-wrap: wrap; gap: 9px; }
  .searchwrap { order: 3; flex-basis: 100%; max-width: none; }
  .barspacer { display: none; }
  .grid { grid-template-columns: 1fr; }
  .mode button { padding: 7px 9px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
