:root {
  --bg: #f6f3ec;
  --surface: #ffffff;
  --ink: #2c1a1d;
  --muted: #6b5d58;
  --line: #dcd4c6;
  --brand: #3f2327;
  --brand-ink: #ffffff;
  --gold: #b98f45;
  --gold-soft: #f4ead3;
  --danger: #a3261f;
  --danger-soft: #fbe9e7;
  --warn: #8a5a00;
  --warn-soft: #fdf0d2;
  --ok: #1e6b34;
  --ok-soft: #e4f3e8;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); }
h1 { font-size: 22px; line-height: 1.25; margin: 0; }
h2 { font-size: 17px; margin: 24px 0 8px; }
p { margin: 8px 0; }
.muted { color: var(--muted); font-size: 14px; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--brand); color: var(--brand-ink); }
.topbar img { height: 32px; width: auto; border-radius: 4px; background: #fff; padding: 2px; }
.topbar strong { font-size: 16px; }
.page { max-width: 960px; margin: 0 auto; padding: 16px 16px 96px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 12px; }

.nav { position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; color: var(--muted); font-size: 12px; text-decoration: none; }
.nav a.active { color: var(--brand); font-weight: 700; }
.nav a.camera svg { background: var(--brand); color: #fff; border-radius: 50%; padding: 5px; width: 34px; height: 34px; }
.nav svg { width: 24px; height: 24px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.ok { color: var(--ok); border-color: var(--ok); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-btn { position: relative; }
.file-btn:focus-within { outline: 2px solid var(--gold); }

label.field { display: block; margin: 12px 0 0; font-size: 14px; font-weight: 600; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=search], select, textarea { display: block; width: 100%; min-height: 44px; margin-top: 4px; padding: 9px 10px; border: 1px solid #b9ae9d; border-radius: var(--radius); background: #fff; color: var(--ink); font: inherit; font-weight: 400; }
textarea { min-height: 96px; resize: vertical; }
label.check { display: flex; align-items: center; gap: 8px; min-height: 40px; font-size: 15px; }
input[type=checkbox] { width: 20px; height: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { min-height: 36px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 18px; background: var(--gold-soft); color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; }

.map-scroll { overflow-x: auto; border-radius: var(--radius); background: #dfe6d4; -webkit-overflow-scrolling: touch; }
.map { position: relative; min-width: 760px; }
.map img { display: block; width: 100%; height: auto; }
.map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.map polygon { fill: rgba(255, 255, 255, .12); stroke: rgba(255, 255, 255, .9); stroke-width: 3; cursor: pointer; }
.map polygon:hover, .map polygon:focus { fill: rgba(255, 255, 255, .4); outline: none; }
.map polygon.some { fill: rgba(233, 169, 33, .55); stroke: #8a5a00; }
.map polygon.many { fill: rgba(190, 40, 30, .55); stroke: #7c1a14; }
.map text { font: 700 30px system-ui, sans-serif; fill: #fff; stroke: #2c1a1d; stroke-width: 7px; paint-order: stroke; text-anchor: middle; pointer-events: none; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 14px; margin-right: 5px; border: 1px solid var(--muted); border-radius: 3px; vertical-align: -2px; }
.legend .l0 { background: #fff; }
.legend .l1 { background: #e9a921; }
.legend .l2 { background: #be281e; }

.house-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; }
.house-chip { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 56px; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); font-weight: 700; text-decoration: none; }
.house-chip small { font-weight: 500; font-size: 12px; color: var(--muted); }
.house-chip.some { background: var(--warn-soft); border-color: #e9a921; }
.house-chip.some small { color: var(--warn); }
.house-chip.many { background: var(--danger-soft); border-color: var(--danger); }
.house-chip.many small { color: var(--danger); }

.card { display: block; margin: 8px 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: inherit; text-decoration: none; }
.card-title { font-weight: 700; overflow-wrap: anywhere; }
.card-meta { margin-top: 4px; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.card-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.nowe { background: var(--danger-soft); color: var(--danger); }
.badge.przekazane { background: var(--warn-soft); color: var(--warn); }
.badge.wykonane { background: var(--ok-soft); color: var(--ok); }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.thumbs img { display: block; width: 72px; height: 72px; border-radius: 6px; object-fit: cover; background: var(--line); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.photo-cell { position: relative; }
.photo-cell img { display: block; width: 100%; aspect-ratio: 1; border-radius: 8px; object-fit: cover; background: var(--line); }
.photo-cell small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.photo-x { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: rgba(44, 26, 29, .8); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 10px; }
.notice { margin: 12px 0; padding: 10px 12px; border-radius: var(--radius); background: var(--gold-soft); font-size: 15px; overflow-wrap: anywhere; }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.empty { padding: 24px 12px; color: var(--muted); text-align: center; }
details.block { margin: 12px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
details.block summary { min-height: 28px; font-weight: 700; cursor: pointer; }

.login { max-width: 400px; margin: 0 auto; padding: 40px 16px; }
.login img { display: block; width: 180px; margin: 0 auto 16px; }

.toast { position: fixed; z-index: 30; left: 16px; right: 16px; bottom: 74px; max-width: 480px; margin: 0 auto; padding: 12px 14px; border-radius: var(--radius); background: var(--ink); color: #fff; text-align: center; }
.toast.error { background: var(--danger); }
dialog { width: min(440px, calc(100vw - 32px)); padding: 16px; border: 0; border-radius: 12px; color: var(--ink); }
dialog::backdrop { background: rgba(44, 26, 29, .5); }
