:root {
  --ground: #f3f2ee;
  --card: #ffffff;
  --ink: #15171c;
  --muted: #5e6168;
  --line: #e2e0da;
  --field: #d6d3cc;
  --ai: #2b59c3;
  --ai-ink: #1e4290;
  --ok: #1d6b3a;
  --warn-bg: #fff1d6;
  --warn: #7a4a00;
  --danger: #9a2a12;
  --radius: 14px;
  --bar-h: 84px;
  font-family: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--ai); }
.mono { font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* uklad */
.shell { min-height: 100dvh; }
.main { max-width: 640px; margin: 0 auto; padding: 0 16px calc(var(--bar-h) + 40px + env(safe-area-inset-bottom)); }
.split { display: block; }
.aside { display: none; }
@media (min-width: 1080px) {
  .split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(420px, 46%); gap: 24px; max-width: 1500px; margin: 0 auto; padding: 0 24px; }
  .split .main { max-width: none; margin: 0; padding-left: 0; padding-right: 0; }
  .aside { display: block; position: sticky; top: 16px; height: calc(100dvh - 32px); margin-top: 16px; }
  .aside iframe { width: 100%; height: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 8px 24px rgba(21, 23, 28, .08); }
  .aside .aside-label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
  .aside .aside-frame { height: calc(100% - 26px); }
  .split .main { padding-bottom: 24px; }
  .split .bar { position: sticky; bottom: 0; padding-left: 0; padding-right: 0; margin-top: 24px; }
  .split .bar-inner { max-width: none; margin: 0; }
  .split .toast { bottom: 110px; }
}

.top { display: flex; align-items: center; gap: 8px; padding: max(14px, env(safe-area-inset-top)) 0 10px; position: sticky; top: 0; background: var(--ground); z-index: 5; }
.top h1 { font-size: 26px; margin: 0; flex: 1; }
.top .titles { flex: 1; min-width: 0; }
.top .t1 { font-weight: 700; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .t2 { font-size: 13px; color: var(--muted); }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; color: var(--ink); }
.icon-btn:hover { background: rgba(21, 23, 28, .06); }
.icon-btn.boxed { border: 1px solid var(--field); background: var(--card); width: 46px; height: 46px; }

.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--ground); border-top: 1px solid var(--line); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
.bar-inner { max-width: 640px; margin: 0 auto; display: flex; gap: 10px; }

/* przyciski */
.btn { min-height: 50px; border-radius: var(--radius); border: 0; font-weight: 600; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; padding: 0 18px; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--ink); color: #fff; flex: 1; }
.btn-ai { background: var(--ai); color: #fff; width: 100%; }
.btn-ghost { background: var(--card); color: var(--ink); border: 1px solid var(--field); }
.btn-ghost.ai { color: var(--ai); border-color: var(--ai); }
.btn-dashed { background: transparent; border: 1.5px dashed #b9b5ac; width: 100%; white-space: nowrap; }
.btn-danger { background: var(--card); color: var(--danger); border: 1px solid #e6b9ad; }
.btn-sm { min-height: 40px; font-size: 14px; padding: 0 14px; border-radius: 999px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

/* pola */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.pad { padding: 14px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 6px; }
.input { width: 100%; min-height: 46px; border: 1px solid var(--field); border-radius: 12px; padding: 11px 12px; font-size: 16px; background: var(--card); }
.input:focus { outline: 2px solid var(--ai); outline-offset: -1px; border-color: var(--ai); }
textarea.input { resize: vertical; line-height: 1.45; min-height: 80px; }
.money { position: relative; }
.money .input { padding-right: 34px; }
.money span { position: absolute; right: 13px; top: 13px; color: var(--muted); pointer-events: none; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; line-height: 1.4; }
.section-h { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 24px 0 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.section-h .mono { text-transform: none; letter-spacing: 0; font-weight: 500; }
.pill { display: inline-flex; align-items: center; background: var(--ground); border-radius: 8px; padding: 6px 10px; font-size: 13px; color: var(--muted); }

/* chipy */
.chip { min-height: 40px; border-radius: 999px; padding: 0 14px; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; border: 1px solid var(--field); background: var(--card); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tag { display: inline-flex; align-items: center; min-height: 24px; border-radius: 999px; padding: 0 9px; font-size: 12px; font-weight: 600; }
.rek-wymiana { background: #fbe3dc; color: #9a2a12; }
.rek-naprawa { background: #ddf0e3; color: #1d6b3a; }
.rek-regulacja { background: #dce8fa; color: #1e4e9a; }
.rek-szkoda { background: #ece1f7; color: #5b2b8c; }
.chip.rek-wymiana, .chip.rek-naprawa, .chip.rek-regulacja, .chip.rek-szkoda { border-color: transparent; }
.chip.on.rek-wymiana { background: #9a2a12; color: #fff; }
.chip.on.rek-naprawa { background: #1d6b3a; color: #fff; }
.chip.on.rek-regulacja { background: #1e4e9a; color: #fff; }
.chip.on.rek-szkoda { background: #5b2b8c; color: #fff; }
.st-draft { background: var(--warn-bg); color: var(--warn); }
.st-approved { background: #ddf0e3; color: var(--ok); }
.st-sent { background: #e6e4de; color: #3e4148; }

/* listy */
.list { display: flex; flex-direction: column; gap: 10px; }
.item { text-align: left; padding: 14px; cursor: pointer; width: 100%; display: flex; gap: 12px; text-decoration: none; color: inherit; }
.item:hover { border-color: #c9c5bc; }
.item .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.item .name { font-weight: 700; font-size: 17px; }
.item .sub { font-size: 15px; }
.item .meta { font-size: 12px; color: var(--muted); }
.nr { width: 28px; height: 28px; border-radius: 8px; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; flex: none; }
.dmg-title { font-weight: 600; font-size: 16px; line-height: 1.3; }
.state-raw { color: var(--ai); font-size: 12px; font-weight: 600; }
.state-ok { color: var(--ok); font-size: 12px; font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; line-height: 1.5; }

/* zdjecia */
.photos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.photo-tile { aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden; border: 0; padding: 0; cursor: pointer; background: #e9e6df; position: relative; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile.busy { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
.add-tile { aspect-ratio: 1 / 1; border-radius: 10px; border: 1.5px dashed #b9b5ac; background: var(--card); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-weight: 600; font-size: 13px; cursor: pointer; }
.viewer { position: fixed; inset: 0; background: rgba(10, 11, 14, .94); z-index: 50; display: flex; flex-direction: column; }
.viewer img { flex: 1; min-height: 0; object-fit: contain; width: 100%; }
.viewer .bar-inner { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }

/* AI */
.warn { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 10px 12px; font-size: 14px; line-height: 1.4; }
.warn ul { margin: 4px 0 0; padding-left: 18px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--ok); line-height: 1.4; }
.overlay { position: fixed; inset: 0; background: rgba(243, 242, 238, .82); z-index: 40; display: flex; align-items: center; justify-content: center; }
.overlay .card { padding: 16px 20px; font-weight: 600; color: var(--ai); display: flex; gap: 10px; align-items: center; }
.spin { width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* arkusz (bottom sheet) */
.sheet-bg { position: fixed; inset: 0; background: rgba(21, 23, 28, .35); z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--ground); width: 100%; max-width: 640px; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 88dvh; overflow-y: auto; }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 20px; } }
.sheet h2 { margin: 0 0 6px; font-size: 20px; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--bar-h) + 24px + env(safe-area-inset-bottom)); z-index: 60; max-width: 560px; margin: 0 auto; background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.4; }
.toast.err { background: var(--danger); }
.banner { border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.4; margin-bottom: 12px; }
.banner.ok { background: #ddf0e3; color: var(--ok); }

.preview-frame { width: 100%; height: calc(100dvh - 170px); border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.login { max-width: 420px; margin: 0 auto; padding: 72px 16px 140px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; }
.avatar { width: 36px; height: 36px; border-radius: 999px; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; border: 0; cursor: pointer; }
.saving { font-size: 12px; color: var(--muted); }
.saving.err { color: var(--danger); }
