/* ── Reset & Variables ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #0f1117;
  --surface: #181c27;
  --surface2:#1e2333;
  --border:  #2a3050;
  --accent:  #4a9eff;
  --accent2: #2ecc8b;
  --warn:    #f5a623;
  --text:    #e8eaf0;
  --muted:   #7a84a0;
  --danger:  #e05555;
  --purple:  #a78bfa;
}

body {
  font-family: 'IBM Plex Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Header ────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.logo {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: .04em;
  text-decoration: none;
}
.logo em { color: var(--muted); font-style: normal; font-size: .8rem; }
.hdr-right { display: flex; align-items: center; gap: .625rem; }

/* ── Buttons ───────────────────────────────────────── */
.hdr-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
}
.hdr-btn:hover { border-color: var(--accent); color: var(--accent); }
.hdr-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.hdr-btn.primary:hover { opacity: .85; }
.hdr-btn.danger { border-color: var(--danger); color: var(--danger); }

.cart-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  transition: opacity .15s;
  text-decoration: none;
}
.cart-btn:hover { opacity: .85; }
.cbadge {
  background: #fff;
  color: var(--accent);
  border-radius: 50%;
  width: 18px; height: 18px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sbtn {
  width: 100%;
  background: var(--accent2);
  border: none;
  color: #0a1a10;
  padding: 12px;
  border-radius: 7px;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: opacity .15s;
}
.sbtn:hover { opacity: .85; }
.sbtn:disabled { opacity: .4; cursor: not-allowed; }

/* ── User pill ─────────────────────────────────────── */
.user-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px 4px 4px;
  font-size: 12px;
}
.u-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--purple);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff;
}

/* ── Controls bar ──────────────────────────────────── */
.controls {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .7rem 1.5rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.search-wrap { flex: 1; min-width: 180px; position: relative; }
.search-wrap input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px 8px 34px;
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}
.search-wrap input:focus { border-color: var(--accent); }
.si { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }
select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 11px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}
select:focus { border-color: var(--accent); }
.rc { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ── Main layout ───────────────────────────────────── */
.main { display: grid; grid-template-columns: 1fr 316px; min-height: calc(100vh - 130px); }
.parts-section { padding: 1.25rem 1.5rem; overflow-y: auto; }

/* ── Table ─────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: var(--surface2);
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; cursor: pointer; }
tbody tr:hover { background: var(--surface); }
td { padding: 9px 12px; vertical-align: middle; }
.pn { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--accent); font-weight: 500; }
.sub-pn { font-size: 11px; color: var(--muted); }

/* Badges */
.db { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.bn  { background: #1a3a4a; color: var(--accent); }   /* OEM            — blue   */
.bc  { background: #1a3a2a; color: var(--accent2); } /* Capa Tier 1    — green  */
.br  { background: #3a2a10; color: var(--warn); }    /* Remanufactured — amber  */
.bp  { background: #2a1a3a; color: var(--purple); }  /* Aftermarket    — purple */
.bt  { background: #0d2a28; color: #2ec4b6; }        /* Recycled       — teal   */
.type-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.t1  { background: var(--accent2); }  /* Capa Tier 1  — green  */
.t2  { background: var(--accent); }   /* OEM          — blue   */
.t4  { background: var(--warn); }     /* Remanufactured — amber */
.t5  { background: var(--purple); }   /* Aftermarket  — purple */
.t6  { background: #2ec4b6; }         /* Recycled     — teal   */

.add-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: opacity .15s;
}
.add-btn:hover { opacity: .8; }

/* ── Cart panel ────────────────────────────────────── */
.cart-panel { background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.cart-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.cart-head h3 { font-size: .9rem; font-weight: 600; }
.cart-head span { font-size: 12px; color: var(--muted); }
.cart-empty { padding: 2rem; text-align: center; color: var(--muted); font-size: 13px; }
.ce-icon { font-size: 2rem; opacity: .4; margin-bottom: .5rem; }
.cart-list { flex: 1; overflow-y: auto; padding: .5rem 0; }
.ci { display: flex; gap: .75rem; padding: .6rem 1.25rem; border-bottom: 1px solid var(--border); align-items: flex-start; }
.ci-info { flex: 1; min-width: 0; }
.ci-pn { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-desc { font-size: 11px; color: var(--muted); }
.qty-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.qb { background: var(--surface2); border: 1px solid var(--border); color: var(--text); width: 22px; height: 22px; border-radius: 4px; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; transition: border-color .12s; }
.qb:hover { border-color: var(--accent); color: var(--accent); }
.qn { font-size: 12px; font-weight: 500; min-width: 16px; text-align: center; }
.rm { background: none; border: none; color: var(--border); cursor: pointer; font-size: 16px; padding: 0; line-height: 1; transition: color .12s; flex-shrink: 0; }
.rm:hover { color: var(--danger); }
.cart-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); }
.tr-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: .25rem; }
.gr-row { display: flex; justify-content: space-between; font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }
.co-btn { width: 100%; background: var(--accent2); border: none; color: #0a1a10; padding: 11px; border-radius: 7px; font-family: inherit; font-weight: 600; font-size: 14px; cursor: pointer; transition: opacity .15s; }
.co-btn:hover { opacity: .85; }
.co-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Modal ─────────────────────────────────────────── */
.mbg { position: fixed; inset: 0; background: rgba(0,0,0,.8); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }
.modal-lg { max-width: 520px; }
.mh { padding: 1.2rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.mh h2 { font-size: 1.05rem; font-weight: 600; }
.mx { background: none; border: none; color: var(--muted); font-size: 1.4rem; cursor: pointer; line-height: 1; }
.mx:hover { color: var(--text); }
.mb { padding: 1.5rem; }

/* ── Forms ─────────────────────────────────────────── */
.fg { margin-bottom: .875rem; }
.fg label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; font-weight: 500; }
.fg input, .fg select, .fg textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}
.fg input:focus, .fg select:focus, .fg textarea:focus { border-color: var(--accent); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

/* ── Order summary ─────────────────────────────────── */
.os { background: var(--bg); border-radius: 8px; padding: .875rem; margin-bottom: 1.25rem; font-size: 12px; font-family: 'IBM Plex Mono', monospace; }
.os .lbl { color: var(--muted); font-size: 11px; margin-bottom: .5rem; text-transform: uppercase; letter-spacing: .06em; }
.ol { display: flex; justify-content: space-between; color: var(--text); padding: 2px 0; overflow: hidden; }
.ol span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: .5rem; }
.ot { display: flex; justify-content: space-between; font-weight: 600; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 8px; font-size: 13px; }

/* ── Status / alerts ───────────────────────────────── */
.st { font-size: 12px; text-align: center; margin-top: .5rem; min-height: 18px; color: var(--muted); }
.st.ok  { color: var(--accent2); }
.st.err { color: var(--danger); }
.alert { padding: .75rem 1rem; border-radius: 6px; font-size: 13px; margin-bottom: 1rem; }
.alert-err  { background: #2a1010; border: 1px solid var(--danger); color: #f0a0a0; }
.alert-ok   { background: #0d2218; border: 1px solid var(--accent2); color: #80e0b0; }

/* ── Pagination ────────────────────────────────────── */
.pg { display: flex; align-items: center; gap: .5rem; padding: 1rem 0; justify-content: center; flex-wrap: wrap; }
.pgb { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 6px 12px; border-radius: 5px; font-size: 12px; cursor: pointer; font-family: inherit; transition: all .12s; }
.pgb:hover { border-color: var(--accent); color: var(--accent); }
.pgb.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.pgb:disabled { opacity: .4; cursor: not-allowed; }

/* ── Auth page ─────────────────────────────────────── */
body.auth-page { display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2rem; width: 100%; max-width: 420px; }
.auth-logo { display: block; font-family: 'IBM Plex Mono', monospace; font-size: 1.1rem; font-weight: 500; color: var(--accent); text-decoration: none; margin-bottom: 1.5rem; }
.auth-logo em { color: var(--muted); font-style: normal; }
.auth-card h1 { font-size: 1.3rem; font-weight: 600; margin-bottom: 1.25rem; }
.auth-alt { text-align: center; font-size: 12px; color: var(--muted); margin-top: .875rem; }
.auth-alt a { color: var(--accent); text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; }

/* ── Success screen ────────────────────────────────── */
.success-wrap { text-align: center; padding: 2rem 1rem; }
.success-wrap .si { font-size: 3rem; margin-bottom: 1rem; }
.success-wrap h3 { font-size: 1.2rem; color: var(--accent2); margin-bottom: .5rem; }
.success-wrap p { font-size: 13px; color: var(--muted); }

/* ── Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 768px) {
  .main { grid-template-columns: 1fr; }
  .cart-panel { border-left: none; border-top: 1px solid var(--border); }
  .form-row { grid-template-columns: 1fr; }
}

/* Product Picture button */
.img-badge {
  display: inline-block;
  margin-top: 5px;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--accent2);
  color: #0a1a10;
  text-decoration: none;
  cursor: pointer;
  border: none;
  letter-spacing: .02em;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: opacity .15s, transform .1s;
}
.img-badge:hover  { opacity: .85; transform: translateY(-1px); }
.img-badge:active { transform: translateY(0); opacity: 1; }
