:root {
  --bg: #f6f7f9; --card: #fff; --fg: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --accent: #1f6feb; --accent-fg: #fff; --chip: #eef2f7; --danger: #c62828;
  --flash: #e8f3e8; --flash-line: #9ccc9c; --error: #fdecea; --error-line: #f1a39b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --card: #1b1f27; --fg: #e6e9ef; --muted: #9aa3b2; --line: #2c323d;
    --accent: #4c8dff; --chip: #262c37; --danger: #ef6b6b;
    --flash: #1d3221; --flash-line: #2f6b39; --error: #3a1d1d; --error-line: #7a2f2f;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .95em; }
h1 { font-size: 1.45rem; margin: .2em 0 .4em; }
h2 { font-size: 1.1rem; margin: 1.2em 0 .5em; }
.card h2:first-child { margin-top: 0; }

.top { display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--fg); }
.top nav { display: flex; gap: .9rem; flex-wrap: wrap; }
main { max-width: 1150px; margin: 0 auto; padding: 1rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; margin: 0 0 1rem; }
.cards { display: grid; gap: .6rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .35rem 0; }
.grow { flex: 1 1 14rem; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: .45rem .6rem; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button, .btn { background: var(--accent); color: var(--accent-fg); border: 0; border-radius: 7px;
  padding: .5rem .9rem; cursor: pointer; display: inline-block; font-weight: 500; }
button.ghost, .btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button.danger { background: var(--danger); }
button.link { background: none; color: var(--accent); padding: 0; font-weight: normal; }
button.link.danger, .danger.link { color: var(--danger); }
.check { display: inline-flex; gap: .3rem; align-items: center; }
label { display: block; }

.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .6rem .8rem; margin-top: .6rem; }
.grid-form label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--muted); }
.grid-form label input, .grid-form label select, .grid-form label textarea { color: var(--fg); font-size: 15px; }
.grid-form .wide { grid-column: 1 / -1; }
details > summary { cursor: pointer; margin: .3rem 0; }

.flash { background: var(--flash); border: 1px solid var(--flash-line); border-radius: 8px; padding: .55rem .8rem; margin-bottom: 1rem; }
.flash.error { background: var(--error); border-color: var(--error-line); }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-size: .8rem; color: var(--muted); font-weight: 600; }
table.results td.desc { max-width: 28rem; }
table.specs th { width: 13rem; font-weight: 500; }
.chip { display: inline-block; background: var(--chip); border-radius: 999px; padding: .05rem .55rem; margin: .1rem .15rem .1rem 0; font-size: .82rem; white-space: nowrap; color: var(--fg); }
.badge { font-size: .75rem; background: var(--chip); padding: .15rem .5rem; border-radius: 6px; vertical-align: middle; font-weight: 500; }

.part-head { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1rem; flex-wrap: wrap; }
.part-img { width: 110px; height: 110px; object-fit: contain; background: #fff; border-radius: 8px; border: 1px solid var(--line); }
.notes { white-space: pre-wrap; background: var(--chip); padding: .5rem .7rem; border-radius: 8px; }
.candidate { display: flex; gap: .8rem; align-items: center; margin: 0; }
.candidate img { width: 56px; height: 56px; object-fit: contain; background: #fff; border-radius: 6px; }
.actions { gap: 1rem; }
.codes code { display: inline-block; margin: .15rem .3rem .15rem 0; }
.match { border-top: 1px solid var(--line); padding-top: .4rem; }

/* lot / count page — phone first */
.count .current { margin-bottom: .5rem; }
.count .big input { font-size: 2rem; width: 9rem; padding: .3rem .6rem; }
.count .big select { font-size: 1.1rem; padding: .6rem; }
.count button.primary { width: 100%; font-size: 1.15rem; padding: .8rem; margin-top: .8rem; }
.reader { width: 100%; max-width: 480px; margin: 0 auto; border-radius: 10px; overflow: hidden; background: #000; min-height: 200px; }

@media (max-width: 640px) {
  main { padding: .7rem; }
  .top { gap: .5rem; padding: .5rem .7rem; }
  .top nav { gap: .7rem; font-size: .95rem; }
  table.results thead { display: none; }
  table.results tr { display: block; border-bottom: 1px solid var(--line); padding: .4rem 0; }
  table.results td { display: block; border: 0; padding: .1rem 0; }
  table.specs th { width: auto; }
}

/* --- auth ------------------------------------------------------------------ */
.top .user-nav { margin-left: auto; }
.auth-box { max-width: 460px; margin: 2rem auto; }
.auth-box h1 { text-align: center; }
.wide-btn { width: 100%; padding: .75rem; font-size: 1.05rem; }
.badge.status-pending, .badge.pending-count { background: #f5b301; color: #000; }
.badge.status-disabled { background: #c0392b; color: #fff; }
.badge.status-active { background: #2e9d5b; color: #fff; }
