:root {
  --bg: #f6f4ef; --card: #ffffff; --ink: #1f2328; --muted: #6b6f76; --line: #e4e0d6;
  --accent: #e3a008; --accent-ink: #3d2b00; --ok: #2a9d4b; --warn: #c0392b; --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: #1e5fb4; }
h1 { font-size: 1.5rem; margin: .4em 0; }
h2 { font-size: 1.15rem; margin: 1.6em 0 .6em; }
code { background: #eee9dc; padding: .1em .35em; border-radius: 4px; }
.container { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.muted { color: var(--muted); font-weight: normal; }
.small { font-size: .85rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.inline { display: inline; }
.plain { list-style: none; padding: 0; margin: 0; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .6rem 1rem; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 10; }
.topbar a { color: #fff; text-decoration: none; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; }
.brand img { width: 28px; }
.topbar nav { display: flex; gap: 1rem; align-items: center; }
.topbar .link { color: #cfd3d8; }

button, .button { font: inherit; border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: .45rem .8rem; cursor: pointer; color: var(--ink); text-decoration: none; display: inline-block; }
button:hover, .button:hover { border-color: #bdb6a5; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.link { background: none; border: 0; padding: 0; color: #1e5fb4; text-decoration: underline; }
.danger { color: var(--warn); }
input, select, textarea { font: inherit; padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; max-width: 100%; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--muted); }
label input, label select, label textarea { color: var(--ink); }

.flash { background: #fff6d8; border: 1px solid #f0d27a; padding: .6rem .9rem; border-radius: 8px; margin-bottom: 1rem; }
.error { color: var(--warn); }
.warn { background: #fff1ee; padding: .5rem; border-radius: 6px; }

.chip { display: inline-flex; align-items: center; gap: .3em; font-size: .8rem; padding: .1em .55em; border-radius: 99px;
  background: color-mix(in srgb, var(--c) 15%, white); color: color-mix(in srgb, var(--c) 75%, black); font-weight: 600; }
.chip::before { content: ""; width: .6em; height: .6em; border-radius: 50%; background: var(--c); }
.chip.none { background: #eee; color: var(--muted); }
.chip.none::before { display: none; }
.badge.copy { background: #e6ddff; color: #4a2f9c; font-weight: 600; }
.badge { font-size: .75rem; padding: .1em .5em; border-radius: 6px; background: #eee; white-space: nowrap; }
.st-todo { background: #eceae4; } .st-progress { background: #fff1c2; } .st-complete { background: #d8f2df; }
.st-incomplete { background: #ffe1d9; } .badge.boxed { background: #dbe8fb; color: #1d4f91; }
.progress.boxed span { background: #3b7dd8; }
h2.sub { font-size: 1.15rem; margin: 1rem 0 0; }
.swatch { display: inline-block; width: .85em; height: .85em; border-radius: 3px; background: var(--c); border: 1px solid #0003; vertical-align: -1px; }
.swatch.trans { opacity: .6; background-image: linear-gradient(135deg, transparent 45%, #fff8 50%, transparent 55%); }

.progress { height: 8px; background: #ece7db; border-radius: 99px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--ok); }
.progress.big { height: 14px; margin: .5rem 0; }

.login-page main { display: grid; place-items: center; min-height: 100vh; }
.login { width: min(360px, 92vw); display: flex; flex-direction: column; gap: 1rem; text-align: center; }
.login-logo { width: 64px; margin: 0 auto; }

.grid-status { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; margin-top: 1rem; }
.stat { display: flex; justify-content: space-between; align-items: center; text-decoration: none; color: inherit; }
.stat strong { font-size: 1.4rem; }
.owners-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .6rem; }
.owner-card { border-top: 5px solid var(--c); }
.owner-card h3 { margin: 0 0 .3rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .6rem; }
.fact { display: flex; flex-direction: column; gap: .3rem; }
.fact img { width: 100%; height: 120px; object-fit: contain; }
.fact ol { margin: .2rem 0 0; padding-left: 1.2rem; }
.bars { list-style: none; padding: 0; margin: .3rem 0 0; display: grid; gap: .25rem; }
.bars li { display: grid; grid-template-columns: 3.5em 1fr 2em; align-items: center; gap: .4rem; font-size: .85rem; }
.bars .bar { height: 10px; background: var(--accent); border-radius: 4px; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0 1rem; }
.filters input[type=search] { flex: 1 1 200px; }
.bulkbar { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: .5rem .8rem; position: sticky; top: 52px; z-index: 5; margin-bottom: .8rem; }
.bulkbar .group { display: flex; gap: .3rem; }
.selall { flex-direction: row; align-items: center; color: var(--ink); }
.set-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .6rem; }
.set-card { display: grid; grid-template-columns: auto 80px 1fr; gap: .6rem; align-items: center; padding: .6rem;
  border-left: 6px solid var(--c); }
.set-card .thumb img { width: 80px; height: 64px; object-fit: contain; }
.set-card .meta { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.set-card .num { font-weight: 700; text-decoration: none; color: var(--ink); }
.set-card .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick { width: 1.2rem; height: 1.2rem; }
.add { margin-top: 1.5rem; }
.add summary { cursor: pointer; }

.detail { display: grid; grid-template-columns: minmax(200px, 320px) 1fr; gap: 1rem; align-items: start; }
.detail-img { border-top: 6px solid var(--c); }
.detail-img img { width: 100%; max-height: 260px; object-fit: contain; }
.actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; margin-top: 1rem; }
.form-grid .wide { grid-column: 1 / -1; display: flex; gap: 1rem; align-items: center; }
.form-grid label.wide { flex-direction: column; align-items: stretch; }
.danger-zone { margin-top: 2rem; text-align: right; }

.items { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.items .item { background: #fff; border: 1px solid var(--line); border-radius: 10px; display: flex; gap: .6rem; align-items: center; padding: .4rem .6rem; }
.items .item > img, .items .tap img { width: 56px; height: 56px; object-fit: contain; flex: none; }
.items .info { display: flex; flex-direction: column; gap: .1rem; min-width: 0; flex: 1; }
.items .info strong { font-size: .92rem; font-weight: 600; }
.items .qty { font-weight: 700; font-size: 1.1rem; }
.items.compact .item > img { width: 40px; height: 40px; }

.check-page .container { padding-bottom: 6rem; }
.check-head { display: flex; gap: .6rem; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: .5rem; position: sticky; top: 52px; z-index: 5; }
.check-head img { width: 56px; height: 44px; object-fit: contain; }
.check-head .back { font-size: 1.4rem; text-decoration: none; padding: 0 .3rem; }
.check-tools { display: flex; flex-wrap: wrap; gap: .5rem; margin: .6rem 0 .3rem; align-items: center; }
.check-tools input[type=search] { flex: 1 1 180px; }
.check-tools label { flex-direction: row; align-items: center; }
.hint { color: var(--muted); margin: .2rem 0 .6rem; }
.check-page .item { flex-wrap: wrap; padding: .3rem; }
.tap { all: unset; display: flex; gap: .6rem; align-items: center; flex: 1 1 260px; min-width: 0; cursor: pointer; padding: .2rem; border-radius: 8px; }
.tap:active { background: #f3efe4; }
.tap .count { font-size: 1.1rem; white-space: nowrap; padding: 0 .4rem; }
.ctrl { display: flex; gap: .3rem; margin-left: auto; }
.ctrl button { min-width: 2.6rem; min-height: 2.6rem; }
.ctrl .miss { color: var(--warn); }
body:not(.mode-count) .count-only, body.mode-count .default-only { display: none !important; }
body:not(.mode-count) .tap { cursor: default; }
body:not(.mode-count) .tap:active { background: none; }
.miss-total { color: var(--warn); }
.mode-count .item.done { background: #eaf7ee; border-color: #bfe5c9; }
.mode-count .item.partial { background: #fffaea; }
.item.has-missing { background: #fff0ec; border-color: #f3c2b5; }
.item.busy { opacity: .5; }
.finish { position: fixed; bottom: 0; left: 0; right: 0; padding: .7rem; background: #fffffff0; border-top: 1px solid var(--line); text-align: center; }
.finish button { width: min(480px, 100%); padding: .8rem; }

.missing-list li[data-recover] { padding: .15rem 0; }
.missing-list li.gone { text-decoration: line-through; opacity: .5; }
.owners-table td, .owners-table th { padding: .3rem .5rem; text-align: left; }
.owners-table input[type=color] { width: 3rem; height: 2.2rem; padding: 2px; }

@media (max-width: 640px) {
  .detail { grid-template-columns: 1fr; }
  .topbar { position: static; padding: .5rem .8rem; }
  .check-head { top: 0; }
  .ctrl button { min-width: 2.4rem; min-height: 2.4rem; }
  .topbar nav { gap: .7rem; font-size: .95rem; }
  .bulkbar { position: static; }
}
