/* ArtIn PWA */
:root {
  --accent: #1e5bc6;
  --accent-soft: rgba(30, 91, 198, .12);
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #000000;
  --text-2: rgba(60, 60, 67, .62);
  --text-3: rgba(60, 60, 67, .32);
  --sep: rgba(60, 60, 67, .2);
  --fill: rgba(118, 118, 128, .12);
  --bar: rgba(249, 249, 249, .86);
  --danger: #d70015;
  --ok: #248a3d;
  --s-available: #248a3d;
  --s-exhibited: #1e5bc6;
  --s-loaned: #c93400;
  --s-sold: #8944ab;
  --s-gifted: #d30f45;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #5c93f0;
    --accent-soft: rgba(92, 147, 240, .18);
    --bg: #000000;
    --card: #1c1c1e;
    --text: #ffffff;
    --text-2: rgba(235, 235, 245, .6);
    --text-3: rgba(235, 235, 245, .3);
    --sep: rgba(84, 84, 88, .6);
    --fill: rgba(118, 118, 128, .24);
    --bar: rgba(22, 22, 23, .86);
    --danger: #ff6961;
    --ok: #30d158;
    --s-available: #30d158;
    --s-exhibited: #5c93f0;
    --s-loaned: #ff9f0a;
    --s-sold: #bf5af2;
    --s-gifted: #ff375f;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* ── nawigacja ── */
.bar {
  position: sticky; top: 0; z-index: 10;
  padding: calc(var(--safe-top) + 6px) 8px 6px;
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--sep);
}
.bar-row { display: flex; align-items: center; min-height: 40px; gap: 4px; }
.bar-title { flex: 1; text-align: center; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-side { flex: 0 0 96px; display: flex; gap: 2px; align-items: center; }
.bar-side.end { justify-content: flex-end; }
.bar-btn {
  border: 0; background: none; color: var(--accent);
  min-width: 40px; height: 40px; padding: 0 8px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  font-size: 17px; white-space: nowrap;
}
.bar-btn:active { opacity: .4; }
.bar-btn.bold { font-weight: 600; }
.bar-btn:disabled { color: var(--text-3); }
.bar-btn svg { width: 24px; height: 24px; }
.bar-home .bar-title { text-align: left; padding-left: 8px; }
.logo {
  display: inline-block;
  background: currentColor;
  -webkit-mask: url(logo.svg) center / auto 190% no-repeat;
  mask: url(logo.svg) center / auto 190% no-repeat;
}
.bar-logo { width: 74px; height: 28px; color: var(--accent); vertical-align: middle; }

.search {
  display: flex; align-items: center; gap: 6px;
  margin: 4px 8px 2px; padding: 0 10px; height: 36px;
  border-radius: 10px; background: var(--fill); color: var(--text-2);
}
.search svg { width: 18px; height: 18px; flex: none; }
.search input { flex: 1; border: 0; background: none; outline: none; color: var(--text); min-width: 0; font-size: 17px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 8px 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 0; border-radius: 16px; padding: 5px 12px; font-size: 14px;
  background: var(--fill); color: var(--text);
}
.chip.on { background: var(--accent); color: #fff; }
select.chip { -webkit-appearance: none; appearance: none; padding-right: 12px; }

main { padding: 8px 16px calc(var(--safe-bottom) + 32px); max-width: 720px; margin: 0 auto; }

/* ── listy ── */
.group { background: var(--card); border-radius: var(--radius); overflow: hidden; margin: 0 0 8px; }
.group-head { font-size: 13px; text-transform: uppercase; color: var(--text-2); margin: 22px 16px 6px; display: flex; justify-content: space-between; align-items: end; gap: 8px; }
.group-head button { border: 0; background: none; color: var(--accent); font-size: 13px; text-transform: none; padding: 0; }
.group-foot { font-size: 13px; color: var(--text-2); margin: 6px 16px 0; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 16px; min-height: 44px; position: relative;
  border: 0; background: none; text-align: left; text-decoration: none; color: var(--text);
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--sep); }
.row.thumbed + .row.thumbed::before { left: 84px; }
a.row:active, button.row:active { background: var(--fill); }
.row-main { flex: 1; min-width: 0; }
.row-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-value { color: var(--text-2); text-align: right; max-width: 60%; overflow-wrap: anywhere; }
.row .chev { color: var(--text-3); width: 14px; height: 14px; flex: none; }
.row-icon { width: 29px; height: 29px; border-radius: 7px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.row-icon svg { width: 18px; height: 18px; }
.row.action { color: var(--accent); }
.row.danger { color: var(--danger); }
.row.disabled { opacity: .4; pointer-events: none; }
.row.multiline { align-items: flex-start; flex-direction: column; gap: 2px; }
.row.multiline .row-value { text-align: left; max-width: none; color: var(--text); white-space: pre-wrap; }
.row-label { font-size: 14px; color: var(--text-2); }

.thumb {
  width: 56px; height: 56px; border-radius: 8px; flex: none; object-fit: cover;
  background: var(--fill); display: grid; place-items: center; color: var(--text-3); overflow: hidden;
}
.thumb svg { width: 24px; height: 24px; }
.thumb.small { width: 44px; height: 44px; border-radius: 6px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 10px;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent);
}
.badge.dot { padding: 0; width: 10px; height: 10px; border-radius: 5px; background: var(--c); }

.count { text-align: center; font-size: 13px; color: var(--text-2); margin: 14px 0; }

.empty { text-align: center; padding: 48px 16px; color: var(--text-2); }
.empty .logo { width: 180px; height: 70px; color: var(--accent); margin-bottom: 12px; }
.empty h2 { color: var(--text); font-size: 22px; margin: 8px 0 6px; }
.empty p { margin: 0 0 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 12px 20px; font-weight: 600;
  background: var(--accent); color: #fff; text-decoration: none;
}
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.wide { width: 100%; }
.btn:active { opacity: .7; }
.btn:disabled { opacity: .4; }
.btn svg { width: 20px; height: 20px; }

/* ── formularz ── */
.field { display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 44px; position: relative; }
.field + .field::before, .row + .field::before, .field + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--sep); }
.field > span { flex: none; min-width: 92px; white-space: nowrap; color: var(--text); }
.field > span.unit { width: auto; }
.field input, .field select, .field textarea {
  flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: 11px 0; text-align: right;
  font-size: 17px; -webkit-appearance: none; appearance: none;
}
.field select { direction: rtl; color: var(--text-2); }
.field select option { direction: ltr; }
.field textarea { text-align: left; resize: vertical; min-height: 96px; }
.field.stack { flex-direction: column; align-items: stretch; gap: 0; padding-top: 8px; }
.field.stack > span { width: auto; font-size: 14px; color: var(--text-2); }
.field input::placeholder, .field textarea::placeholder { color: var(--text-3); }
.field .unit { color: var(--text-2); flex: none; }
.field .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.dims { display: flex; flex: 1; min-width: 0; justify-content: flex-end; align-items: center; gap: 4px; }
.dims input { flex: 1 1 0; min-width: 0; max-width: 64px; text-align: center; background: var(--fill); border-radius: 8px; padding: 6px 4px; }
.dims b { color: var(--text-3); font-weight: 400; }
.warn { color: var(--danger); font-size: 13px; margin: 6px 16px 0; }

.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.slot {
  position: relative; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden;
  background: var(--card); display: grid; place-items: center; text-align: center;
  border: 1.5px dashed var(--sep); color: var(--accent);
}
.slot.has { border: 0; }
.slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slot input { position: absolute; inset: 0; opacity: 0; font-size: 0; cursor: pointer; }
.slot .slot-label { font-size: 14px; display: grid; gap: 6px; justify-items: center; }
.slot .slot-label svg { width: 30px; height: 30px; }
.slot .slot-tag { position: absolute; left: 8px; bottom: 8px; font-size: 12px; font-weight: 600; color: #fff; background: rgba(0,0,0,.5); padding: 3px 8px; border-radius: 8px; }
.slot .slot-del { position: absolute; top: 6px; right: 6px; z-index: 2; width: 30px; height: 30px; border-radius: 15px; border: 0; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; }
.slot .slot-del svg { width: 16px; height: 16px; }
.slot.busy::after { content: "Przetwarzam…"; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.45); color: #fff; font-size: 14px; }

/* ── szczegóły ── */
.pager { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 8px; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
.pager::-webkit-scrollbar { display: none; }
.pager figure { flex: 0 0 100%; margin: 0; scroll-snap-align: center; position: relative; }
.pager img { width: 100%; max-height: 62vh; object-fit: contain; background: var(--card); border-radius: var(--radius); display: block; }
.pager figcaption { position: absolute; left: 10px; bottom: 10px; font-size: 12px; font-weight: 600; color: #fff; background: rgba(0,0,0,.5); padding: 3px 8px; border-radius: 8px; }
.detail-head { margin: 14px 4px 10px; }
.detail-head h1 { font-size: 26px; margin: 0; line-height: 1.15; }
.detail-head .meta { color: var(--text-2); margin-top: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }

.label-card { background: #fff; color: #000; border-radius: 8px; padding: 10px; display: block; width: 100%; height: auto; border: .5px solid rgba(0,0,0,.15); }
.label-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }

.viewer { position: fixed; inset: 0; z-index: 50; background: #000; overflow: auto; display: grid; place-items: center; touch-action: pinch-zoom pan-x pan-y; }
.viewer img { max-width: 100vw; max-height: 100vh; object-fit: contain; }
.viewer button { position: fixed; top: calc(var(--safe-top) + 10px); right: 12px; width: 36px; height: 36px; border-radius: 18px; border: 0; background: rgba(255,255,255,.2); color: #fff; display: grid; place-items: center; }
.viewer button svg { width: 18px; height: 18px; }

/* ── skaner ── */
.scanner { position: fixed; inset: 0; z-index: 40; background: #000; color: #fff; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; left: 50%; top: 45%; width: 64vw; max-width: 300px; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 24px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); border: 3px solid rgba(255,255,255,.9); }
.scanner .top { position: absolute; top: 0; left: 0; right: 0; padding: calc(var(--safe-top) + 10px) 12px 10px; display: flex; justify-content: space-between; align-items: center; }
.scanner .top button { border: 0; background: rgba(255,255,255,.2); color: #fff; padding: 8px 16px; border-radius: 18px; font-weight: 600; }
.scanner .hint { position: absolute; left: 16px; right: 16px; bottom: calc(var(--safe-bottom) + 40px); text-align: center; font-size: 15px; }
.scanner .hint b { display: inline-block; background: rgba(0,0,0,.55); padding: 8px 14px; border-radius: 12px; font-weight: 500; }

/* ── różne ── */
.status-line { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; font-size: 15px; }
.status-line.ok { color: var(--ok); }
.status-line.err { color: var(--danger); }
.status-line svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.token { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 15px; letter-spacing: .02em; flex: 1; user-select: all; -webkit-user-select: all; overflow-wrap: anywhere; }
.check { width: 24px; height: 24px; flex: none; color: var(--text-3); }
.check.on { color: var(--accent); }
.switch { -webkit-appearance: none; appearance: none; width: 51px; height: 31px; border-radius: 16px; background: var(--fill); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 14px; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .2s; }
.switch:checked { background: #34c759; }
.switch:checked::after { transform: translateX(20px); }
.seg { display: inline-flex; background: var(--fill); border-radius: 8px; padding: 2px; flex: none; }
.seg button { border: 0; background: none; padding: 4px 12px; border-radius: 6px; font-size: 13px; font-weight: 500; }
.seg button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.mini { border: 0; background: none; color: var(--accent); padding: 6px; display: grid; place-items: center; }
.mini svg { width: 20px; height: 20px; }
.mini:disabled { color: var(--text-3); }
.mini.danger { color: var(--danger); }

.about { text-align: center; padding: 24px 8px 8px; display: grid; gap: 4px; justify-items: center; }
.about .logo { width: 150px; height: 56px; color: var(--accent); }
.about .tagline { font-weight: 500; font-size: 15px; }
.about .concept { font-size: 13px; color: var(--text-2); }
.about .site { font-size: 13px; font-weight: 500; margin-top: 2px; }
.about .small { font-size: 11px; color: var(--text-3); }

.progress { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; margin: 8px 0; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.35); display: grid; place-items: center; padding: 24px; }
.dialog { background: var(--card); border-radius: 16px; padding: 20px; width: min(340px, 100%); text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.dialog h3 { margin: 0 0 6px; font-size: 17px; }
.dialog p { margin: 0 0 16px; font-size: 14px; color: var(--text-2); overflow-wrap: anywhere; }
.dialog input { width: 100%; border: .5px solid var(--sep); border-radius: 8px; padding: 8px 10px; margin: 0 0 16px; background: var(--bg); font-size: 17px; }
.dialog .actions { display: grid; gap: 8px; }
.dialog .btn { width: 100%; }
.dialog .btn.danger { background: var(--danger); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--fill); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 4px auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 24px); z-index: 70;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: rgba(30,30,30,.92); color: #fff; padding: 10px 16px; border-radius: 14px;
  font-size: 15px; max-width: calc(100vw - 32px); text-align: center; transition: opacity .25s, transform .25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.install { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; font-size: 14px; }
.install svg { width: 22px; height: 22px; flex: none; color: var(--accent); }

/* ── druk: katalog i etykieta ── */
#print { display: none; }
@media print {
  @page { size: A4; margin: 16mm; }
  body { background: #fff; color: #000; font-size: 11pt; }
  #app, #toast, .overlay { display: none !important; }
  #print { display: block; }
  .p-page { page-break-after: always; break-after: page; }
  .p-page:last-child { page-break-after: auto; break-after: auto; }
  .p-cover { height: 240mm; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 6mm; }
  .p-cover .logo { width: 90mm; height: 34mm; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .p-cover h1 { font-size: 26pt; margin: 0; }
  .p-cover p { margin: 0; color: #444; }
  .p-cover .p-foot { margin-top: auto; font-size: 9pt; color: #666; }
  .p-photo { width: 100%; height: 150mm; object-fit: contain; display: block; margin-bottom: 8mm; }
  .p-nophoto { height: 40mm; border: .3mm dashed #aaa; display: grid; place-items: center; color: #888; margin-bottom: 8mm; }
  .p-work h2 { font-size: 18pt; font-style: italic; margin: 0 0 1mm; }
  .p-work .p-num { font-family: Menlo, monospace; color: #444; margin-bottom: 5mm; }
  .p-work table { border-collapse: collapse; width: 100%; }
  .p-work td { padding: 1.5mm 0; border-bottom: .2mm solid #ddd; vertical-align: top; }
  .p-work td:first-child { color: #666; width: 45mm; }
  .p-label { width: 120mm; border: .3mm solid #ccc; }
}
