/* ============ Lidy Okazje — design system ============ */
:root {
  --bg: #f4f5f8;
  --card: #ffffff;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --line: #e8eaef;
  --line-2: #d9dde5;
  --primary: #111827;
  --primary-2: #111827;
  --accent: #4f46e5;
  --accent-2: #4f46e5;
  --accent-soft: #eef0fe;
  --danger: #dc2626;
  --ok: #16a34a;
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, .05);
  --shadow-md: 0 2px 6px rgba(17, 24, 39, .06), 0 10px 28px -12px rgba(17, 24, 39, .14);
  --shadow-lg: 0 12px 40px -12px rgba(17, 24, 39, .25);
  --ring: 0 0 0 3px rgba(79, 70, 229, .25);
  --t: .18s cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 20px rgba(11, 18, 32, .25);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 18px; letter-spacing: .01em; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent);
  color: #fff; font-weight: 900; font-size: 14px;
  box-shadow: 0 2px 8px rgba(79, 70, 229, .4);
}
#topbar-extra { font-size: 13.5px; color: #b6c2d8; font-weight: 500; }
#topbar-extra .btn { min-height: 36px; }

/* ---------- layout ---------- */
.container { max-width: 1000px; margin: 0 auto; padding: 18px 14px 110px; }
@media (min-width: 720px) { .container { padding: 26px 22px 80px; } }
.loading { text-align: center; color: var(--muted); padding: 70px 0; font-weight: 500; }
.loading::after { content: '…'; animation: dots 1.2s steps(3) infinite; }
@keyframes dots { 0% { content: ''; } 33% { content: '·'; } 66% { content: '··'; } }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 23px; margin: 0; letter-spacing: -.01em; }
.page-head .sub { color: var(--muted); font-size: 14px; width: 100%; }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: 16px;
  margin-bottom: 14px;
  transition: box-shadow var(--t), transform var(--t);
}
@media (min-width: 720px) and (hover: hover) {
  .card.lead-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
}

.lead-card { display: flex; flex-direction: column; gap: 11px; }
.lead-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.lead-title { font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.lead-loc { color: var(--muted); font-size: 13.5px; margin-top: 1px; }
.lead-date { color: var(--muted); font-size: 12px; white-space: nowrap; background: #f4f6fb; padding: 3px 9px; border-radius: 999px; }

.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; padding: 4px 11px; border-radius: 999px;
  background: #f3f4f8; border: 1px solid #e3e5ee;
  font-size: 12px; font-weight: 600; color: #4b5563;
}
.badge.client { background: var(--accent-soft); border-color: #dfe1fb; color: var(--accent); }
.badge.st-aktualna { background: #dcfce7; border-color: #bbf7d0; color: #15803d; }
.badge.st-wybrana { background: var(--accent-soft); border-color: #dfe1fb; color: var(--accent); }
.badge.st-zakonczona { background: #f3f4f6; border-color: #e5e7eb; color: #6b7280; }
.badge.st-odrzucona { background: #fee2e2; border-color: #fecaca; color: #b91c1c; }

.status-select {
  padding: 7px 10px; min-height: 36px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line-2); border-radius: 10px; background: #fff;
  color: var(--ink-2); cursor: pointer; font-family: inherit;
}
.status-select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }

.prices { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.price b { display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 2px; }
.price span { font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.price.main span { font-size: 19px; color: var(--accent); }

.lead-desc { font-size: 14.5px; color: var(--ink-2); }
.lead-desc > *:first-child { margin-top: 0; }
.lead-desc > *:last-child { margin-bottom: 0; }
.lead-desc p { margin: 0 0 8px; }
.lead-desc ul, .lead-desc ol { margin: 6px 0; padding-left: 20px; }
.lead-desc li { margin-bottom: 3px; }
.lead-notes {
  font-size: 13px; color: var(--muted); font-style: italic; white-space: pre-wrap;
  border-left: 3px solid var(--line-2); padding-left: 10px;
}

/* ---------- zdjęcia ---------- */
.photos { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
.photos::-webkit-scrollbar { height: 6px; }
.photos::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; }
.photos img {
  height: 96px; width: 96px; object-fit: cover; border-radius: 12px;
  border: 1px solid var(--line); cursor: zoom-in; flex: 0 0 auto;
  background: #e2e8f0; scroll-snap-align: start;
  transition: transform var(--t), box-shadow var(--t);
}
.photos img:hover { transform: scale(1.03); box-shadow: var(--shadow-md); }
.photos.grid { flex-wrap: wrap; overflow: visible; }
.photos.grid img { height: 110px; width: calc(33.33% - 6px); min-width: 92px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 12px; border: 1px solid transparent;
  font-size: 15px; font-weight: 700; cursor: pointer; text-decoration: none;
  background: var(--primary);
  color: #fff; min-height: 46px; letter-spacing: .01em;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t), box-shadow var(--t), filter var(--t);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:hover { filter: brightness(1.08); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.accent {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px -4px rgba(79, 70, 229, .5);
}
.btn.ghost { background: #fff; color: var(--ink-2); border-color: var(--line-2); box-shadow: none; }
.btn.ghost:hover { border-color: var(--accent); color: var(--ink); filter: none; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 7px 13px; min-height: 36px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 40;
  width: 62px; height: 62px; border-radius: 50%; border: none;
  background: var(--accent);
  color: #fff; font-size: 32px; font-weight: 700; line-height: 1;
  box-shadow: 0 8px 24px rgba(79, 70, 229, .45), var(--shadow-lg);
  cursor: pointer;
  transition: transform var(--t);
}
.fab:active { transform: scale(.93); }
@media (min-width: 720px) { .fab { display: none; } }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--ink-2); }
.field label .req { color: var(--danger); }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 13px; font-size: 16px;
  border: 1.5px solid var(--line-2); border-radius: var(--r-md);
  background: #fff; color: var(--ink); font-family: inherit;
  transition: border-color var(--t), box-shadow var(--t);
}
.field textarea { min-height: 90px; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: #a2aec4; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--ring);
}
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 620px) {
  .form-row.cols-2 { grid-template-columns: 1fr 1fr; }
  .form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}
.form-error {
  background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
  padding: 11px 13px; border-radius: var(--r-md); font-size: 14px; margin-bottom: 12px; font-weight: 500;
}

/* ---------- edytor HTML ---------- */
.rt-toolbar { display: flex; gap: 5px; flex-wrap: wrap; margin: 8px 0 6px; }
.rt-toolbar button {
  min-width: 40px; height: 38px; padding: 0 12px;
  border: 1px solid var(--line-2); background: #fff; border-radius: var(--r-sm);
  cursor: pointer; font-size: 14px; color: var(--ink-2); font-weight: 600;
  transition: background var(--t), border-color var(--t);
}
.rt-toolbar button:hover { border-color: var(--accent); }
.rt-toolbar button:active { background: var(--accent-soft); }
.rt-editor {
  min-height: 130px; padding: 12px 13px;
  border: 1.5px solid var(--line-2); border-radius: var(--r-md); background: #fff;
  font-size: 16px; line-height: 1.55; outline: none;
  transition: border-color var(--t), box-shadow var(--t);
}
.rt-editor:focus { border-color: var(--accent); box-shadow: var(--ring); }
.rt-editor:empty::before { content: attr(data-ph); color: #a2aec4; pointer-events: none; }
.rt-editor p { margin: 0 0 8px; }
.rt-editor ul, .rt-editor ol { margin: 6px 0; padding-left: 20px; }
.rt-editor li { margin-bottom: 3px; }

/* ---------- photo picker ---------- */
.photo-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.photo-slot {
  position: relative; width: 86px; height: 86px; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line); background: #e2e8f0; box-shadow: var(--shadow-sm);
}
.photo-slot img { width: 100%; height: 100%; object-fit: cover; }
.photo-slot .rm {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px;
  border-radius: 50%; border: none; background: rgba(15, 23, 42, .78); color: #fff;
  font-size: 13px; line-height: 1; cursor: pointer; backdrop-filter: blur(4px);
}
.photo-add {
  width: 86px; height: 86px; border-radius: 12px; border: 2px dashed #c3cddd;
  background: #f8fafc; color: var(--muted); font-size: 28px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color var(--t), color var(--t), background var(--t);
}
.photo-add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(11, 18, 32, .55); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: #fff; width: 100%; max-width: 660px; max-height: 92vh;
  border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto;
  animation: slideUp .28s cubic-bezier(.32, .72, .35, 1);
}
.modal::before {
  content: ''; display: block; width: 42px; height: 4px; border-radius: 99px;
  background: var(--line-2); margin: 0 auto 12px;
}
@keyframes slideUp { from { transform: translateY(60px); opacity: .6; } }
@media (min-width: 640px) {
  .modal-back { align-items: center; padding: 24px; }
  .modal { border-radius: 20px; }
  .modal::before { display: none; }
}
.modal h2 { margin: 0 0 16px; font-size: 20px; letter-spacing: -.01em; }
.modal-close {
  float: right; border: none; background: #f1f5f9; border-radius: 10px;
  width: 36px; height: 36px; font-size: 16px; cursor: pointer; color: var(--ink-2);
}
.modal-close:hover { background: #e2e8f0; }

/* ---------- tabs ---------- */
.tabs {
  display: flex; gap: 4px; margin-bottom: 18px; overflow-x: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 4px; box-shadow: var(--shadow-sm);
}
.tabs button {
  flex: 1; white-space: nowrap; padding: 10px 14px; border-radius: 10px;
  border: none; background: transparent; color: var(--muted);
  font-size: 14px; font-weight: 700; cursor: pointer; min-height: 42px;
  transition: background var(--t), color var(--t);
}
.tabs button.active {
  background: var(--primary);
  color: #fff; box-shadow: var(--shadow-sm);
}

/* ---------- rejestr ---------- */
.registry {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-md); overflow: hidden;
}
.reg-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px; border-bottom: 1px solid var(--line);
  cursor: pointer; transition: background var(--t);
}
.reg-row:last-child { border-bottom: none; }
.reg-row:hover { background: #f7f8fb; }
.reg-row:active { background: #f0f2f8; }
.reg-thumb {
  width: 52px; height: 52px; border-radius: 10px; overflow: hidden; flex: 0 0 auto;
  background: #eef0f4; display: flex; align-items: center; justify-content: center;
  color: #aab3c2; font-size: 18px;
}
.reg-thumb img { width: 100%; height: 100%; object-fit: cover; }
.reg-main { flex: 1; min-width: 0; }
.reg-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reg-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reg-price { font-weight: 800; font-size: 14px; white-space: nowrap; color: var(--ink); }
.reg-date { font-size: 12px; color: var(--muted); white-space: nowrap; }
.reg-chev { color: #b6bfce; font-size: 22px; font-weight: 700; flex: 0 0 auto; }
.reg-status { flex: 0 0 auto; }
.reg-row .badge { flex: 0 0 auto; }

/* status jako symbol */
.st-dot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; }
.st-dot.st-aktualna { background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }
.st-dot.st-wybrana { background: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
.st-dot.st-zakonczona { background: #9ca3af; box-shadow: 0 0 0 3px rgba(156, 163, 175, .18); }
.st-dot.st-odrzucona { background: #dc2626; box-shadow: 0 0 0 3px rgba(220, 38, 38, .15); }

.only-sm { display: none; }
@media (max-width: 719px) {
  .hide-sm { display: none; }
  .only-sm { display: inline; }
  .st-dot.only-sm { display: inline-block; }
  .reg-row { padding: 11px 12px; gap: 10px; }
  .reg-thumb { width: 48px; height: 48px; }
  .reg-title { font-size: 15.5px; }
  .reg-sub { font-size: 12.5px; }
}

/* ---------- chipsy (filtry) ---------- */
.chips { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.chips button {
  white-space: nowrap; padding: 8px 15px; border-radius: 999px;
  border: 1px solid var(--line-2); background: #fff;
  font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer;
  min-height: 38px; flex: 0 0 auto;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.chips button:hover { border-color: var(--accent); }
.chips button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 56px 20px; }
.empty .big { font-size: 46px; margin-bottom: 10px; opacity: .8; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; word-break: break-all; }

.toast {
  position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 120;
  background: var(--primary); color: #fff; padding: 13px 22px;
  border-radius: 999px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn .3s cubic-bezier(.32, .72, .35, 1);
}
@keyframes toastIn { from { transform: translate(-50%, 16px); opacity: 0; } }
.toast.err { background: var(--danger); }

.lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, .93);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
  animation: fadeIn .18s ease;
  touch-action: none;
}
.lightbox img {
  max-width: 92vw; max-height: 86vh; border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5); cursor: default;
}
.lb-close, .lb-nav {
  position: fixed; z-index: 210; border: none; cursor: pointer;
  background: rgba(255, 255, 255, .14); color: #fff;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t);
}
.lb-close:hover, .lb-nav:hover { background: rgba(255, 255, 255, .28); }
.lb-close {
  top: calc(12px + env(safe-area-inset-top)); right: 14px;
  width: 44px; height: 44px; border-radius: 50%; font-size: 18px;
}
.lb-nav {
  top: 50%; transform: translateY(-50%);
  width: 50px; height: 50px; border-radius: 50%; font-size: 28px; line-height: 1;
}
.lb-prev { left: 10px; }
.lb-next { right: 10px; }
.lb-count {
  position: fixed; bottom: calc(18px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); z-index: 210;
  color: #fff; background: rgba(0, 0, 0, .55);
  padding: 6px 15px; border-radius: 999px; font-size: 13px; font-weight: 600;
}

.landing { text-align: center; padding: 70px 20px; }
.landing h1 { font-size: 34px; letter-spacing: -.02em; margin-bottom: 10px; color: var(--ink); }
.landing p { color: var(--muted); max-width: 480px; margin: 0 auto 28px; font-size: 15.5px; }

.link-box {
  display: flex; align-items: center; gap: 8px; background: #f8fafc;
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 9px 11px;
}
.link-box .mono { flex: 1; }

.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-left: 6px; }
.status-dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, .18); }
.status-dot.off { background: var(--danger); box-shadow: 0 0 0 3px rgba(220, 38, 38, .15); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- native app feel (PWA) ---------- */
html { -webkit-text-size-adjust: 100%; }
body {
  overscroll-behavior-y: none;        /* brak pull-to-refresh i przechodzenia scrolla */
  touch-action: manipulation;         /* brak opóźnienia/double-tap zoom */
}
button, .btn, .reg-row, .chips button, .fab, .topbar,
.lb-nav, .lb-close, .modal-x, .toast, .badge, .tabs button {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}
.modal-body { overscroll-behavior: contain; }
.lead-desc, .lead-notes, input, select, .editor, .mono { user-select: text; -webkit-touch-callout: default; }

/* pasek instalacji */
.install-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 999px;
  padding: 7px 14px; font-size: 13px; font-weight: 700; cursor: pointer;
  min-height: 34px; margin-left: 8px;
}

@media (max-width: 719px) {
  .container { padding-left: 12px; padding-right: 12px; }
}
