/* Same visual language as the printed Word catalogues: Georgia titles, one colour per category, photo cards. */
:root {
  --ink: #1c2333;
  --muted: #6b7280;
  --faint: #a8a29e;
  --line: #e7e2da;
  --paper: #ffffff;
  --photo-bg: #eceef4;
  --tape: #ffd23f;
  --danger: #b42318;
  --accent: #1c2333;          /* overridden per category */
  --serif: Georgia, "Noto Serif", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font: 16px/1.4 var(--sans);
  color: var(--ink);
  background: var(--paper);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 3; background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
  padding: calc(16px + env(safe-area-inset-top)) 16px 0; border-bottom: 1px solid var(--line);
}
.top > * { max-width: 1280px; margin-left: auto; margin-right: auto; }
.titlebar { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
h1 { margin: 0; font: 400 2rem/1.1 var(--serif); letter-spacing: -0.01em; }
#summary { margin: 0; font-size: .875rem; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
#summary b { color: #8a5a00; font-weight: 600; }
#summary .waiting { color: var(--ink); font-weight: 600; }
#search {
  display: block; width: 100%; margin-top: 12px; padding: 12px 14px; font-size: 1rem;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
}
#search:focus-visible { outline: none; border-color: var(--ink); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0; scrollbar-width: none; overscroll-behavior-x: contain; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff;
  font-size: .875rem; white-space: nowrap; cursor: pointer;
}
.chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip[aria-pressed="true"] i { background: #fff; }
.chip.low { --accent: var(--tape); }
.chip.low[aria-pressed="true"] { color: var(--ink); }
.chip.low[aria-pressed="true"] i { background: var(--ink); }

/* Sections + grid */
main { max-width: calc(1280px + 32px); margin: 0 auto; padding: 0 16px; } /* lines up with the header */
.section { margin-top: 26px; }
.section h2 {
  display: flex; align-items: baseline; gap: 10px; margin: 0 0 14px; padding-bottom: 8px;
  font: 400 1.5rem/1.2 var(--serif); border-bottom: 2px solid var(--accent);
}
.section h2 span { margin-left: auto; font: 600 .875rem var(--sans); color: var(--accent); font-variant-numeric: tabular-nums; }
.grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px 14px; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); }

.card { display: flex; flex-direction: column; min-width: 0; }
.photo {
  position: relative; display: block; width: 100%; aspect-ratio: 1; padding: 0; border: 0; cursor: pointer;
  border-radius: 12px; overflow: hidden; background: var(--photo-bg);
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease-out; }
@media (hover: hover) { .photo:hover img { transform: scale(1.03); } }
.photo .none { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); font-size: .8125rem; }
.tag {
  position: absolute; left: 8px; top: 8px; padding: 3px 9px 3px 13px; border-radius: 6px;
  background: var(--tape); color: var(--ink); font-size: .75rem; font-weight: 700; overflow: hidden;
}
.tag::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  background: repeating-linear-gradient(-45deg, var(--tape) 0 3px, var(--ink) 3px 5px); }
.name {
  margin: 9px 0 6px; padding: 0; border: 0; background: none; text-align: left; cursor: pointer;
  font-weight: 600; font-size: .9375rem; line-height: 1.3; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.stepper { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.step {
  width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--line); background: #fff;
  font-size: 1.25rem; line-height: 1; cursor: pointer; display: grid; place-items: center;
  touch-action: manipulation; transition: transform .1s ease-out;
}
.step:active { transform: scale(.9); }
.step.plus { background: var(--accent); border-color: var(--accent); color: #fff; }
.step:disabled { opacity: .3; cursor: default; }
.qty { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; min-width: 2.5ch; }
.qty.unknown { font-size: .75rem; font-weight: 600; color: var(--muted); line-height: 1.1; }
.card.is-low .qty { color: #8a5a00; }

.empty { padding: 48px 24px; text-align: center; color: var(--muted); }

/* Bottom bar */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; gap: 10px; justify-content: center;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.95); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
.btn {
  min-height: 46px; padding: 0 18px; border-radius: 12px; border: 1.5px solid var(--line);
  background: #fff; font-weight: 600; cursor: pointer; touch-action: manipulation;
}
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.bar .primary { flex: 1; max-width: 340px; }
.btn.danger { color: var(--danger); border-color: transparent; background: none; padding: 0 6px; }

/* Dialogs: bottom sheet on phones, centred on PC */
dialog {
  border: 0; padding: 0 0 calc(16px + env(safe-area-inset-bottom)); width: 100%; max-width: 520px;
  margin: auto auto 0; border-radius: 18px 18px 0 0; background: #fff; color: var(--ink);
  max-height: 92dvh; overflow: auto;
}
dialog[open] { animation: sheet .24s cubic-bezier(.2,.8,.2,1); }
@keyframes sheet { from { transform: translateY(28px); opacity: 0; } }
dialog::backdrop { background: rgba(28,35,51,.5); }
@media (min-width: 640px) { dialog { margin: auto; border-radius: 18px; padding-bottom: 16px; } }
dialog > form, dialog > h2, dialog > ol, dialog > .actions { margin-left: 18px; margin-right: 18px; }
dialog > h2 { margin-top: 20px; }
#item-photo { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--photo-bg); }
#item-form { margin: 0; }
#item-form > :not(img) { margin-left: 18px; margin-right: 18px; }
#item-title { margin-top: 18px; }
h2 { margin: 0 0 14px; font: 400 1.5rem/1.2 var(--serif); }
form label { display: block; margin-bottom: 12px; font-size: .875rem; font-weight: 600; color: var(--muted); }
form input, form select {
  display: block; width: 100%; margin-top: 4px; padding: 11px 12px; font-size: 1rem; font-weight: 400;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.error { color: var(--danger); margin: 0 0 10px; font-weight: 600; }
.actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.spacer { flex: 1; }

.history { list-style: none; padding: 0; }
.history li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.history .what { font-weight: 600; }
.history .meta { color: var(--muted); font-size: .8125rem; }
.history .detail { font-size: .9375rem; font-variant-numeric: tabular-nums; }

/* Screens: one visible at a time */
body:not([data-screen="login"]) #login, body:not([data-screen="app"]) #app { display: none; }
body[data-screen="loading"] { background: var(--paper); }
body:not([data-role="admin"]) .admin-only, body[data-role="viewer"] .editor-only { display: none !important; }
body[data-screen="login"] { padding-bottom: 0; }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 20px; }
.login form { width: 100%; max-width: 360px; }
.login img { border-radius: 16px; display: block; margin-bottom: 18px; }
.login h1 { margin-bottom: 6px; }
.btn.wide { width: 100%; margin-top: 4px; }
.muted { color: var(--muted); font-size: .9375rem; margin: 0 0 16px; }

.avatar {
  flex: none; align-self: center; width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--ink); color: #fff; font-weight: 700; font-size: 1rem;
}
.titlebar #summary { margin-left: auto; }

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset:disabled input, fieldset:disabled select { background: #f6f6f4; color: var(--ink); opacity: 1; }
#password-form { margin-bottom: 18px; }
.ok { color: #0f6e6a; font-weight: 600; margin: 0 0 10px; }

.team { list-style: none; padding: 0; }
.team li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.team .muted { margin: 0; font-size: .8125rem; overflow-wrap: anywhere; }
.team select { padding: 9px 10px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; font-size: .9375rem; }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 4;
  max-width: calc(100% - 32px); margin: 0; padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: #fff; font-size: .9375rem; box-shadow: 0 6px 24px rgba(28,35,51,.25);
}

.update {
  position: fixed; z-index: 5; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 24px); display: flex; align-items: center; gap: 14px;
  padding: 8px 8px 8px 16px; border-radius: 14px; background: #fff; border: 1.5px solid var(--line);
  box-shadow: 0 8px 28px rgba(28,35,51,.18); font-weight: 600;
}
.update .btn { min-height: 40px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
