:root {
    --gold: #CEA95C;
    --gold-deep: #7A5C14;
    --gold-soft: #F6EFDC;
    --ink: #1D1A12;
    --ink-muted: #5F5A4C;
    --ink-faint: #8C8675;
    --bg: #F7F5EF;
    --surface: #FFFFFF;
    --surface-sunken: #F1EEE5;
    --border: #E3DECF;
    --header: #17150F;
    --good: #2E7D32;
    --warn: #B26A00;
    --bad: #B3261E;
    --radius: 10px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.4; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--gold-deep); }
button, input, select { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* header */
.top { background: var(--header); color: #fff; display: flex; align-items: center; gap: 16px; padding: 10px 20px; position: sticky; top: 0; z-index: 20; }
.top .logo { height: 54px; width: auto; display: block; }
.top .grow { flex: 1; min-width: 0; }
.top .who { font-size: 13px; text-align: right; line-height: 1.25; }
.top .who b { display: block; font-weight: 600; }
.top .who span { color: #cfc8b4; }
.top button.link { background: none; border: 1px solid #5a5340; color: #fff; border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.top button.link:hover { border-color: var(--gold); color: var(--gold); }

.searchbar { display: flex; gap: 8px; max-width: 640px; margin: 0 auto; }
.searchbar input { flex: 1; min-width: 0; padding: 11px 14px; border-radius: 9px; border: 1px solid #5a5340; background: #fff; color: var(--ink); font-size: 16px; }
.searchbar input::placeholder { color: var(--ink-faint); }

/* buttons */
button.primary, a.primary { background: var(--gold); color: var(--ink); border: 1px solid var(--gold); border-radius: 9px; padding: 10px 18px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block; }
button.primary:hover { filter: brightness(.95); }
button.primary:disabled { opacity: .55; cursor: default; }
button.quiet { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px; cursor: pointer; }
button.quiet:hover { border-color: var(--gold); }
button.danger { background: var(--surface); color: var(--bad); border: 1px solid var(--bad); border-radius: 8px; padding: 7px 12px; cursor: pointer; }

/* layout */
.page { width: 100%; max-width: 1280px; margin: 0 auto; padding: 18px 20px 40px; flex: 1; }
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.filters .field { display: flex; flex-direction: column; gap: 3px; min-width: 190px; flex: 1 1 190px; }
.filters label, .field label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); }
.filters select, .field input, .field select, .field textarea { padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); width: 100%; }
.filters .check { display: flex; align-items: center; gap: 7px; padding-bottom: 9px; white-space: nowrap; }
.count { margin: 14px 2px 10px; color: var(--ink-muted); font-size: 14px; }
.message { padding: 10px 14px; border-radius: 8px; margin: 10px 0; font-size: 14px; }
.message.error { background: #FCEBEA; color: var(--bad); border: 1px solid #F2C4C0; }
.message.ok { background: #EAF5EA; color: var(--good); border: 1px solid #BFDDC0; }
.empty { color: var(--ink-faint); padding: 26px 8px; text-align: center; }

/* result tiles */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; text-align: left; padding: 0; transition: box-shadow .15s, border-color .15s; }
.tile:hover, .tile:focus-visible { border-color: var(--gold); box-shadow: 0 6px 18px rgba(29, 26, 18, .12); outline: none; }
.tile .pic { align-self: stretch; width: 100%; height: 150px; background: var(--surface-sunken); display: flex; align-items: center; justify-content: center; padding: 8px; position: relative; }
.tile .pic img { max-width: 100%; max-height: 100%; object-fit: contain; }
.tile .pic .nophoto, .pcard-tile .nophoto, .detail .photo .nophoto { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--ink-faint); font-size: 11px; width: 100%; }
.nophoto img.ph { width: 70%; max-height: 82px; object-fit: contain; opacity: .9; }
.detail .photo .nophoto img.ph { max-height: 160px; }
.pcard-tile .nophoto img.ph { width: 80%; max-height: 80px; }
.tile .pic .brandlogo { position: absolute; left: 8px; top: 8px; height: 22px; max-width: 70px; object-fit: contain; background: rgba(255,255,255,.85); border-radius: 5px; padding: 2px 4px; }
.tile .body { align-self: stretch; width: 100%; padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.tile .code { font-weight: 700; font-size: 17px; }
.tile .desc { font-size: 12.5px; color: var(--ink-muted); min-height: 34px; }
.tile .via { font-size: 11.5px; color: var(--gold-deep); }
.tile .row { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 6px; font-size: 12.5px; }
.stock.in { color: var(--good); } .stock.low { color: var(--warn); } .stock.out { color: var(--bad); }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin: 22px 0 6px; color: var(--ink-muted); }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(23, 21, 15, .62); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
.dialog { background: var(--surface); border-radius: 14px; width: min(920px, 100%); max-height: calc(100vh - 32px); overflow: auto; position: relative; }
.dialog .hd { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.dialog .hd h2 { margin: 0; font-size: 18px; }
.dialog .bd { padding: 16px 18px 20px; }
.xbtn { background: none; border: 0; font-size: 26px; line-height: 1; cursor: pointer; color: var(--ink-muted); padding: 0 6px; }

/* product card (same design as the PartPilot card) */
.pcard-scene { width: 300px; height: 452px; perspective: 1500px; margin: 0 auto; }
.pcard { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .5s cubic-bezier(.4, .1, .2, 1); }
.pcard.flip { transform: rotateY(180deg); }
.pcard-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 16px; overflow: hidden; background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; box-shadow: 0 8px 22px rgba(23, 21, 15, .22); }
.pcard-back { transform: rotateY(180deg); }
.pcard-accent { height: 4px; background: var(--gold); flex: none; }
.pcard-top { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px 4px; }
.pcard-top img.bl { height: 28px; max-width: 132px; object-fit: contain; }
.pcard-top .bw { font-size: 16px; font-weight: 700; }
.pcard-p { width: 28px; height: 28px; object-fit: contain; opacity: .9; }
.pcard-lbl { font-size: 9px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); }
.pcard-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 4px 14px; cursor: pointer; }
.pcard-tile { width: 178px; height: 128px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-sunken); display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 7px; }
.pcard-tile img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pcard-pn { font-size: 26px; font-weight: 600; }
.pcard-nm { font-size: 11.5px; color: var(--ink-muted); text-align: center; }
.stars { font-size: 14px; }
.stars .on { color: #E8A200; } .stars .off { color: #D8D2C0; }
.premium { display: inline-block; background: #E8A200; color: #3a2a00; font-size: 9px; font-weight: 700; padding: 1px 7px; border-radius: 12px; vertical-align: middle; }
.pcard-strip { display: flex; align-items: flex-end; justify-content: space-between; padding: 8px 16px; border-top: 1px solid var(--border); font-size: 11px; }
.pcard-fits { padding: 7px 16px; border-top: 1px solid var(--border); font-size: 11px; color: var(--ink-muted); min-height: 38px; }
.pcard-make { display: inline-flex; align-items: center; cursor: pointer; margin: 0 8px 4px 0; vertical-align: middle; }
.pcard-make img { height: 22px; max-width: 72px; object-fit: contain; display: block; }
.pcard-make .w { color: var(--gold-deep); font-weight: 600; font-size: 12px; }
.pcard-ft { display: flex; justify-content: space-between; align-items: center; padding: 9px 14px; background: var(--bg); }
.pcard-open { background: var(--gold-soft); color: var(--gold-deep); border: 1px solid var(--gold); border-radius: 7px; padding: 6px 11px; font-size: 12px; font-weight: 600; cursor: pointer; }
.pcard-bkhd { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.pcard-panel { flex: 1; overflow: auto; padding: 10px 13px; }
.pcard-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 2px; border-bottom: 1px solid var(--border); font-size: 13px; }
.pcard-row .sub { font-size: 10.5px; color: var(--ink-muted); }
.pcard-row b { font-weight: 600; }
.xlogo { height: 15px; max-width: 56px; object-fit: contain; vertical-align: middle; margin-right: 4px; }
.xfold { cursor: pointer; margin-top: 10px; color: var(--ink-muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }

/* full product window */
.detail { display: grid; grid-template-columns: 280px 1fr; gap: 20px; }
.detail .photo { background: var(--surface-sunken); border-radius: 12px; display: flex; align-items: center; justify-content: center; min-height: 220px; padding: 10px; }
.detail .photo img { max-width: 100%; max-height: 280px; object-fit: contain; }
.thumbs { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.thumbs img { width: 52px; height: 52px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-sunken); cursor: pointer; }
.detail h3 { margin: 18px 0 6px; font-size: 13px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-muted); }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-muted); padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.t td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: var(--surface-sunken); }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 12px; background: var(--surface-sunken); color: var(--ink-muted); }
.badge.good { background: #EAF5EA; color: var(--good); } .badge.warn { background: #FFF1DC; color: var(--warn); } .badge.bad { background: #FCEBEA; color: var(--bad); }
.howbox { background: var(--gold-soft); border: 1px solid var(--gold); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }

/* login */
.login { margin: auto; width: min(400px, 92vw); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 26px 26px 22px; box-shadow: 0 10px 30px rgba(23, 21, 15, .12); }
.login .logo { display: block; margin: 0 auto 10px; height: 150px; width: 100%; object-fit: contain; background: var(--header); border-radius: 12px; padding: 8px; }
.login h1 { font-size: 19px; text-align: center; margin: 4px 0 16px; }
.login .field { margin-bottom: 12px; }
.login button.primary { width: 100%; margin-top: 4px; }
.footer { text-align: center; color: var(--ink-faint); font-size: 12px; padding: 16px; display: flex; align-items: center; justify-content: center; gap: 7px; }
.footer img { height: 18px; width: 18px; object-fit: contain; }

/* admin */
.admin { display: grid; grid-template-columns: 210px 1fr; flex: 1; min-height: 0; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 14px 10px; }
.side a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; margin-bottom: 2px; }
.side a.on { background: var(--gold-soft); color: var(--gold-deep); font-weight: 600; }
.side a:hover { background: var(--surface-sunken); }
.main { padding: 18px 22px 40px; min-width: 0; }
.main h1 { font-size: 20px; margin: 0 0 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.kpi b { display: block; font-size: 24px; } .kpi span { font-size: 12.5px; color: var(--ink-muted); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; }
.panel h2 { margin: 0 0 10px; font-size: 15px; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.form .wide { grid-column: 1 / -1; }
.inline { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.pics { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.pic { width: 110px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.pic .im { height: 90px; background: var(--surface-sunken); display: flex; align-items: center; justify-content: center; }
.pic .im img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pic .bar { display: flex; justify-content: space-between; padding: 4px 6px; font-size: 11px; gap: 4px; }
.pic .bar button { background: none; border: 0; color: var(--gold-deep); cursor: pointer; padding: 0; font-size: 11px; }
.pic .bar button.rm { color: var(--bad); }
.thumb { width: 44px; height: 44px; object-fit: contain; background: var(--surface-sunken); border-radius: 6px; border: 1px solid var(--border); }
.pwbox { font-family: ui-monospace, Consolas, monospace; font-size: 17px; background: var(--gold-soft); border: 1px dashed var(--gold); border-radius: 8px; padding: 8px 12px; display: inline-block; user-select: all; }

@media (max-width: 760px) {
    .top { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
    .top .logo { height: 38px; }
    .top .grow { order: 5; flex-basis: 100%; }
    .page { padding: 12px 12px 30px; }
    .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .tile .pic { height: 120px; }
    .detail { grid-template-columns: 1fr; }
    .admin { grid-template-columns: 1fr; }
    .side { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 8px; }
    .side a { white-space: nowrap; }
    .main { padding: 14px 12px 30px; }
}

/* photo lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(12, 11, 8, .92); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 20px; }
.lightbox img { max-width: 94vw; max-height: 88vh; object-fit: contain; background: #fff; border-radius: 10px; }
.lightbox .lb-x, .lightbox .lb-nav { position: absolute; background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 50%; width: 44px; height: 44px; font-size: 26px; line-height: 1; cursor: pointer; }
.lightbox .lb-x { top: 16px; right: 16px; }
.lightbox .lb-nav.prev { left: 14px; top: 50%; transform: translateY(-50%); }
.lightbox .lb-nav.next { right: 14px; top: 50%; transform: translateY(-50%); }
.lightbox .lb-count { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; color: #d8d2c0; font-size: 13px; }
.zoomable { cursor: zoom-in; }
.pic.hiddenpic { opacity: .65; }
.pic.hiddenpic .im { filter: grayscale(.6); }

/* bulk pictures */
.dropzone { border: 2px dashed var(--gold); background: var(--gold-soft); border-radius: 14px; text-align: center; padding: 26px 16px; }
.dropzone.over { background: #EFE2BC; border-style: solid; }

/* photo mode */
.pm-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 14px; align-items: end; }
.pm-controls .check { display: flex; align-items: center; gap: 8px; padding-bottom: 4px; }
.pm-row { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px; margin-bottom: 10px; }
.pm-row.is-done { border-color: #BFDDC0; background: #F6FBF6; }
.pm-thumb { width: 76px; height: 76px; flex: none; background: var(--surface-sunken); border-radius: 10px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pm-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pm-thumb .nophoto img.ph { width: 70%; max-height: 40px; }
.pm-thumb .nophoto .cap { display: none; }
.pm-info { flex: 1; min-width: 0; }
.pm-code { font-weight: 700; font-size: 18px; }
.pm-desc { font-size: 13px; color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pm-meta { font-size: 12px; margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pm-st { display: inline-block; font-size: 13px; margin-top: 4px; }
.pm-st.ok { color: var(--good); font-weight: 600; } .pm-st.work { color: var(--gold-deep); } .pm-st.bad { color: var(--bad); }
.pm-note { font-size: 12px; color: var(--warn); }
.pm-extra { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.pm-extra .quiet { padding: 4px 10px; font-size: 12px; }
.pm-cam { flex: none; width: 76px; min-height: 76px; border-radius: 14px; border: 0; background: var(--gold); color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; font-weight: 700; font-size: 13px; }
.pm-cam:disabled { opacity: .5; }
