:root {
  --bg: #f6f4f3;
  --surface: #ffffff;
  --ink: #221e1f;
  --muted: #6b6466;
  --line: #e3dcd9;
  --accent: #a3282f;
  --accent-hover: #861f25;
  --accent-soft: #f8e7e8;
  --ok: #1d7a4a;
  --danger: #b42318;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px; color: var(--ink); background: var(--bg); line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--danger); min-height: 1.2em; margin: 6px 0 0; }

input, select, textarea {
  font: inherit; color: var(--ink); width: 100%;
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
input, select { min-height: 44px; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
input[type="checkbox"] { width: auto; min-height: 0; accent-color: var(--accent); }
label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
label.check-row { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 15px; align-self: end; min-height: 44px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid1 { display: grid; gap: 14px; }
.grid2 { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.btn {
  font: inherit; font-weight: 600; font-size: 15px; cursor: pointer;
  min-height: 44px; padding: 10px 20px; border-radius: 999px;
  border: 1.5px solid var(--accent); background: var(--accent); color: #fff;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--ghost { background: transparent; color: var(--accent); }
.btn--ghost:hover { background: var(--accent-soft); }
.btn--sm { min-height: 40px; padding: 8px 14px; font-size: 14px; }
.btn--block { width: 100%; }
.btn--danger { background: transparent; color: var(--danger); border-color: var(--danger); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login__card { width: min(380px, 100%); display: grid; gap: 14px; }
.login__card h1 { margin: 0; font-size: 1.6rem; }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--ink); color: #fff;
  padding-top: calc(12px + env(safe-area-inset-top));
}
.top__brand { color: #fff; text-decoration: none; font-weight: 700; }
.top .btn--ghost { color: #fff; border-color: rgba(255,255,255,.5); }

.pane { padding: 14px 16px 120px; max-width: 900px; margin: 0 auto; display: grid; gap: 14px; }
.toolbar { display: flex; gap: 8px; align-items: center; }
.toolbar input { flex: 1; }

.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.item {
  display: grid; gap: 2px; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
}
.item:hover { border-color: var(--accent); }
.item__name { font-weight: 700; font-size: 1.05rem; }
.item__meta { font-size: 14px; color: var(--muted); }

.fab {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 8; font: inherit; font-weight: 600; min-height: 48px; padding: 12px 20px;
  border-radius: 999px; border: 0; background: var(--accent); color: #fff; cursor: pointer;
  box-shadow: 0 10px 24px -8px rgba(0,0,0,.4);
}

/* KARTA PSA */
.back { font-size: 14px; color: var(--accent); text-decoration: none; font-weight: 600; }
.dog-head { display: grid; gap: 6px; }
.dog-head h1 { margin: 0; font-size: 1.8rem; line-height: 1.1; }
.kv { display: grid; gap: 4px; font-size: 15px; }
.kv a { color: var(--accent); font-weight: 600; }
.notes { white-space: pre-wrap; background: #fff8e6; border: 1px solid #f1e0a8; border-radius: 10px; padding: 10px 12px; font-size: 15px; }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 0; }
.section-title h2 { margin: 0; font-size: 1.25rem; }

.visit { display: grid; gap: 8px; }
.visit__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: baseline; }
.visit__date { font-weight: 700; }
.visit__service { font-weight: 600; }
.visit__desc { white-space: pre-wrap; font-size: 15px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.badge--tip { background: #e5f4ec; color: var(--ok); }
.badge--price { background: var(--accent-soft); color: var(--accent); }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.thumb { position: relative; border-radius: 10px; overflow: hidden; background: var(--accent-soft); aspect-ratio: 1 / 1; cursor: pointer; border: 0; padding: 0; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumbwrap { position: relative; }
.thumb-del {
  position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%;
  border: 0; background: rgba(34,30,31,.75); color: #fff; cursor: pointer; font-size: 16px; line-height: 1;
}
.thumb span {
  position: absolute; left: 6px; bottom: 6px; font-size: 11px; font-weight: 700;
  background: rgba(34,30,31,.7); color: #fff; padding: 2px 7px; border-radius: 999px;
}

.visit__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.upload { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.upload select { width: auto; min-height: 40px; padding: 6px 10px; }
.upload input[type="file"] { width: auto; min-height: 0; padding: 6px 0; border: 0; }

/* OKNA */
dialog.sheet {
  border: 0; padding: 0; border-radius: 18px; width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px); overflow: auto; background: var(--surface); color: var(--ink);
}
dialog.sheet::backdrop { background: rgba(20,14,12,.55); }
dialog.sheet > form { padding: 20px; }
dialog.sheet h2 { margin: 0; font-size: 1.3rem; }
dialog.photo { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; }
dialog.photo::backdrop { background: rgba(20,14,12,.9); }
dialog.photo img { max-width: 94vw; max-height: 90vh; border-radius: 12px; display: block; }
.photo__close {
  position: fixed; top: 14px; right: 14px; width: 48px; height: 48px; border-radius: 50%;
  border: 0; background: rgba(255,255,255,.2); color: #fff; font-size: 2rem; line-height: 1; cursor: pointer;
}

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 60; max-width: calc(100% - 32px); text-align: center;
}
.toast--bad { background: var(--danger); }

/* NAWIGACJA MODUŁÓW */
.modules { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.modules a { white-space: nowrap; min-height: 40px; display: inline-flex; align-items: center; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 600; }
.modules a[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: #fff; }
