/* Paleta: odcienie zieleni i szarosci. Wszystkie kolory tylko przez zmienne. */
:root {
  --green-900: #25330f;
  --green-800: #394f17;
  --green-700: #557722;
  --green-600: #6c962c;
  --green-500: #7eb438;
  --green-100: #eaf2de;
  --green-50:  #f6f9f0;

  --gray-900: #1f2523;
  --gray-700: #3f4744;
  --gray-500: #6b7470;
  --gray-400: #939b97;
  --gray-300: #c9cfcc;
  --gray-200: #e1e5e3;
  --gray-100: #eef1ef;
  --gray-50:  #f6f7f6;

  --bg: var(--gray-100);
  --card: #ffffff;
  --text: var(--gray-900);
  --muted: var(--gray-500);
  --primary: var(--green-500);
  --primary-hover: var(--green-600);
  --link: var(--green-700);
  --link-hover: var(--green-800);
  --border: var(--gray-200);
  --danger: #b3261e;
  --danger-bg: #fbe9e7;
  --warn: #8a6d1a;
  --warn-bg: #fbf3dc;

  --radius: 8px;
  --topbar-h: 52px;
  --gutter: 1rem;
}

* { box-sizing: border-box; }

html {
  /* Bez samowolnego skalowania tekstu po obrocie telefonu. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  /* Nic nie moze rozepchnac strony w poziomie - ekran "nie lata". */
  overflow-x: hidden;
}

a { color: var(--link); }
a:hover { color: var(--link-hover); }

:focus-visible { outline: 2px solid var(--green-500); outline-offset: 2px; }

/* ---------- Pasek gorny ---------- */
/* Podglad portalu jako inne konto (admin) - czerwony pasek nad naglowkiem. */
.impersonation-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 11;
  height: var(--preview-h);
  padding: 0 var(--gutter);
  background: var(--danger);
  color: #fff;
  font-size: 0.9rem;
}
.impersonation-bar span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Pasek glowny przykleja sie pod paskiem podgladu. */
body.previewing { --preview-h: 2.4rem; }
body.previewing .topbar { top: var(--preview-h); }
button.impersonation-stop {
  flex: none;
  padding: 0 0.55rem;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  color: #fff;
  font-size: 1.2rem;
  line-height: 1.3;
  cursor: pointer;
}
button.impersonation-stop:hover { background: rgba(255, 255, 255, 0.2); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-height: var(--topbar-h);
  padding: 0 1.5rem;
  background: var(--green-500);
  color: #fff;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}
.topbar a { color: #fff; }
.brand { font-weight: 700; font-size: 1.05rem; text-decoration: none; white-space: nowrap; }
.topbar nav { display: flex; gap: 0.25rem; }
.topbar nav a {
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  color: var(--green-100);
  white-space: nowrap;
}
.topbar nav a:hover { background: var(--green-700); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 1.25rem; }
.logout { display: flex; align-items: center; gap: 0.75rem; }
.topbar-company {
  max-width: 22rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
}
.topbar .muted { color: var(--green-100); opacity: 0.8; font-size: 0.85rem; }
.topbar button.link { color: #fff; }
.topbar button.link:hover { color: #fff; }
.langs { display: flex; gap: 0.35rem; }
.lang-option { text-transform: uppercase; font-size: 0.8rem; }
.topbar .lang-option { color: var(--green-100); opacity: 0.75; }
.topbar .lang-current { opacity: 1; color: #fff; font-weight: 700; text-decoration: underline; }
.topbar .lang-option:hover { color: #fff; opacity: 1; }

/* ---------- Uklad strony ---------- */
.page { max-width: 1400px; margin: 1.25rem auto; padding: 0 var(--gutter); }

.card {
  background: var(--card);
  padding: 1.25rem 1.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(37, 51, 15, 0.06);
}
.card.narrow { max-width: 420px; margin: 3rem auto; }

h1 { margin: 0 0 1rem; color: var(--green-800); font-size: 1.35rem; font-weight: 650; }
.muted { color: var(--muted); }

/* ---------- Formularze ---------- */
label { display: block; margin-bottom: 0.9rem; font-size: 0.9rem; color: var(--gray-700); }
label.check { display: flex; gap: 0.5rem; align-items: center; color: var(--text); }

input[type=email], input[type=password], input[type=text], input[type=search], input[type=number], select, textarea {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  /* 16px to minimum, ponizej ktorego iOS przybliza ekran przy focusie. */
  font-size: 16px;
  line-height: 1.3;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(126, 180, 56, 0.25);
}
input[type=checkbox] { accent-color: var(--green-600); width: 1.05rem; height: 1.05rem; }

fieldset { border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 1rem; padding: 0.75rem 1rem; min-width: 0; }
legend { font-size: 0.9rem; color: var(--muted); padding: 0 0.3rem; }

/* ---------- Przyciski ---------- */
button, .button {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.55rem 1rem;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.3;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  touch-action: manipulation;
}
button:hover, .button:hover { background: var(--primary-hover); color: #fff; }
button.secondary { background: var(--green-50); color: var(--link); border-color: var(--green-100); }
button.secondary:hover { background: var(--green-100); color: var(--link-hover); }
button.danger { background: var(--danger); }
button.danger:hover { background: #8f1e18; }
button.link, button.link:hover { background: none; color: var(--link); padding: 0; border: 0; text-align: left; font-size: inherit; }
button.link:hover { text-decoration: underline; }

/* ---------- Pasek narzedzi nad tabela ---------- */
.toolbar { display: flex; align-items: center; gap: 0.75rem 1rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.toolbar h1 { margin: 0; }
.search { display: flex; gap: 0.5rem; margin-left: auto; flex: 0 1 380px; min-width: 0; }
.search input { margin: 0; flex: 1; min-width: 0; }

/* ---------- Tabele: Tabulator (motyw na bazie tabulator_simple) ---------- */
.grid.tabulator {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  font-size: 0.875rem;
  overflow: hidden;
}
.grid .tabulator-header {
  background: var(--gray-50);
  color: var(--gray-700);
  border-bottom: 2px solid var(--green-600);
}
.grid .tabulator-header .tabulator-col { background: var(--gray-50); border-right: 0; }
.grid .tabulator-header .tabulator-col .tabulator-col-content { padding: 0.55rem 0.65rem; }
.grid .tabulator-col-title {
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.grid .tabulator-header .tabulator-col.tabulator-sortable:hover { background: var(--green-50); }
.grid .tabulator-col[aria-sort="ascending"] .tabulator-col-sorter .tabulator-arrow { border-bottom-color: var(--green-700); }
.grid .tabulator-col[aria-sort="descending"] .tabulator-col-sorter .tabulator-arrow { border-top-color: var(--green-700); }
.grid .tabulator-col[aria-sort="ascending"],
.grid .tabulator-col[aria-sort="descending"] { color: var(--green-800); }

.grid .tabulator-tableholder { background: var(--card); }
.grid .tabulator-row { background: var(--card); border-bottom: 1px solid var(--border); min-height: 0; }
.grid .tabulator-row.tabulator-row-even { background: var(--gray-50); }
.grid .tabulator-row.tabulator-selectable:hover,
.grid .tabulator-row:hover { background: var(--green-50); }
.grid .tabulator-row .tabulator-cell { padding: 0.45rem 0.65rem; border-right: 0; }
.grid .tabulator-cell.num { font-variant-numeric: tabular-nums; }
.grid .tabulator-cell a { color: var(--link); font-weight: 500; }

/* Rozwijanie ukrytych kolumn (telefon/tablet). */
.grid .tabulator-responsive-collapse-toggle { background: var(--green-600); border-radius: 50%; width: 18px; height: 18px; }
.grid .tabulator-responsive-collapse { border-top: 1px dashed var(--border); padding: 0.3rem 0.65rem 0.5rem 2.6rem; }
.grid .tabulator-responsive-collapse table { font-size: 0.85rem; border-collapse: collapse; }
.grid .tabulator-responsive-collapse td { padding: 0.15rem 0.75rem 0.15rem 0; vertical-align: top; }
.grid .tabulator-responsive-collapse td:first-child { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; white-space: nowrap; }

.grid .tabulator-placeholder-contents { color: var(--muted); font-size: 0.95rem; font-weight: 400; }
.grid .tabulator-alert { background: rgba(255, 255, 255, 0.7); }
.grid .tabulator-alert .tabulator-alert-msg { border: 1px solid var(--green-600); color: var(--green-800); border-radius: var(--radius); }
.grid .tabulator-alert .tabulator-alert-msg.tabulator-alert-state-error { border-color: var(--danger); color: var(--danger); }

/* Filtry w naglowkach kolumn: przycisk + okienko z polami wyboru (public/js/grid.js, listFilter). */
.grid .tabulator-header-filter { margin-top: 0.35rem; }
.grid button.grid-filter {
  display: block;
  width: 100%;
  padding: 0.25rem 1.4rem 0.25rem 0.45rem;
  font-size: 0.8rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  text-align: left;
  color: var(--muted);
  background: var(--card) no-repeat right 0.45rem center / 0.6rem
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b7470' stroke-width='1.5'/%3E%3C/svg%3E");
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.grid button.grid-filter:hover { border-color: var(--green-500); background-color: var(--card); color: var(--text); }
.grid button.grid-filter.is-active { border-color: var(--green-600); background-color: var(--green-50); color: var(--green-800); font-weight: 600; }

.grid-filter-pop {
  position: fixed;
  z-index: 100;
  min-width: 180px;
  max-width: min(320px, calc(100vw - 16px));
  background: var(--card);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(37, 51, 15, 0.18);
  font-size: 0.875rem;
}
.grid-filter-pop input[type=search] { margin: 0; border: 0; border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.grid-filter-pop input[type=search]:focus { box-shadow: none; border-bottom-color: var(--green-500); }
.grid-filter-pop ul { list-style: none; margin: 0; padding: 0.25rem 0; max-height: 260px; overflow-y: auto; overscroll-behavior: contain; }
.grid-filter-pop li label { display: flex; align-items: center; gap: 0.55rem; margin: 0; padding: 0.35rem 0.75rem; color: var(--text); font-size: 0.875rem; cursor: pointer; }
.grid-filter-pop li label:hover { background: var(--green-50); }
.grid-filter-pop li.grid-filter-empty { padding: 0.35rem 0.75rem; color: var(--muted); }
.grid-filter-foot { border-top: 1px solid var(--border); padding: 0.45rem 0.75rem; text-align: right; }
.grid-filter-foot button.link { font-size: 0.85rem; }
@media (pointer: coarse) {
  .grid-filter-pop li label { padding: 0.6rem 0.9rem; font-size: 1rem; }
}

/* Licznik wierszy pod tabela (tabele sa przewijane, bez stronicowania). */
.grid-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 0.5rem; min-height: 1.2em; }
.grid-count { margin: 0; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.grid-foot button.grid-reset { font-size: 0.85rem; }
.grid-foot button.grid-reset[hidden] { display: none; }
/* Uchwyt zmiany szerokosci kolumny: podswietlony po najechaniu, szerszy na ekranach dotykowych. */
.grid .tabulator-header .tabulator-col-resize-handle:hover { background: var(--green-500); }
@media (pointer: coarse) {
  .grid .tabulator-header .tabulator-col-resize-handle { width: 16px; margin-left: -8px; margin-right: -8px; }
}

/* ---------- Komunikaty i etykiety ---------- */
.alert { padding: 0.7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border-left: 4px solid; }
.alert-success { background: var(--green-100); color: var(--green-800); border-color: var(--green-600); }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

.badge { display: inline-block; font-size: 0.75rem; padding: 0.1rem 0.55rem; border-radius: 999px; background: var(--gray-100); color: var(--gray-700); white-space: nowrap; }
.badge-active { background: var(--green-100); color: var(--green-800); }
.badge-inactive { background: var(--danger-bg); color: var(--danger); }
.badge-pending { background: var(--warn-bg); color: var(--warn); }

.chips, .results { list-style: none; padding: 0; margin: 0 0 0.75rem; }
.chips li { padding: 0.4rem 0; border-bottom: 1px dashed var(--border); }
.results li { padding: 0.3rem 0; }

.actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
/* Ponowne wyslanie zaproszenia: wybor jezyka obok przycisku. */
.actions form.invite { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem; }
label.inline { margin: 0; }
label.inline select { width: auto; min-width: 9rem; }

/* ---------- Raport ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.report-group { display: flex; gap: 0.5rem; align-items: center; min-width: 0; flex: 0 1 420px; }
.report-group label.inline { flex: 1; min-width: 0; }
.report-group label.inline select { width: 100%; margin: 0; }
/* Lista wyboru z wyszukiwaniem (public/js/select_search.js). */
label[hidden] { display: none; }
.select-search { position: relative; flex: 1; min-width: 0; }
.select-search input { margin: 0; text-overflow: ellipsis; }
.select-search ul {
  position: absolute;
  z-index: 100;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  max-height: min(360px, 60vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--card);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(37, 51, 15, 0.18);
  font-size: 0.9rem;
}
.select-search ul[hidden] { display: none; }
.select-search li { padding: 0.4rem 0.75rem; cursor: pointer; }
.select-search li.is-selected { font-weight: 600; color: var(--green-800); }
.select-search li.is-active, .select-search li[role=option]:hover { background: var(--green-50); }
.select-search li.select-search-empty { color: var(--muted); cursor: default; }
@media (pointer: coarse) {
  .select-search li { padding: 0.65rem 0.9rem; font-size: 1rem; }
}
.report-updated { font-size: 0.85rem; margin-left: auto; }
.report-subtitle { margin: 0.5rem 0 0.6rem; font-size: 1rem; font-weight: 600; color: var(--green-800); }
.report-hint { margin: 0; font-size: 0.85rem; flex: 1 1 320px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.stat-box { border: 1px solid var(--border); border-radius: var(--radius); background: var(--gray-50); padding: 0.75rem 1rem; }
.stat-box h3 { margin: 0 0 0.6rem; font-size: 0.9rem; font-weight: 600; color: var(--gray-700); }
.stat-box dl { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5rem 0.75rem; margin: 0; }
.stat-box dt { font-size: 0.75rem; color: var(--muted); line-height: 1.25; }
.stat-box dd { margin: 0.2rem 0 0; font-size: 1.15rem; font-weight: 650; color: var(--green-900); font-variant-numeric: tabular-nums; }
.stat-box dd.change-up { color: var(--green-700); }
.stat-box dd.change-down { color: var(--danger); }
.stat-note { margin: 0.6rem 0 0; font-size: 0.78rem; color: var(--muted); }

.structure { display: flex; align-items: center; justify-content: space-between; gap: 1rem 2rem; margin-bottom: 1.25rem; }
.structure-charts { display: flex; flex-wrap: wrap; gap: 1rem 2rem; flex: 1 1 auto; justify-content: space-around; min-width: 0; }
.structure-chart { margin: 0; flex: 0 1 240px; min-width: 180px; text-align: center; }
.structure-chart figcaption { margin-bottom: 0.4rem; font-size: 0.85rem; font-weight: 600; color: var(--gray-700); }
.structure-plot { aspect-ratio: 1; }
.structure-plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.structure-plot .slice { stroke: var(--card); stroke-width: 1; cursor: default; transition: opacity 0.15s; }
.structure-plot .slice.dim { opacity: 0.25; }
.structure-plot .slice-label { font-size: 11px; font-weight: 600; text-anchor: middle; dominant-baseline: central; pointer-events: none; font-variant-numeric: tabular-nums; transition: opacity 0.15s; }
.structure-plot .slice-label.dim { opacity: 0.15; }
.structure-plot .center-type { font-size: 13px; font-weight: 600; fill: var(--gray-700); text-anchor: middle; }
.structure-plot .center-value { font-size: 19px; font-weight: 650; fill: var(--green-900); text-anchor: middle; font-variant-numeric: tabular-nums; }
.structure-empty { margin: 0; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 0.85rem; border: 1px dashed var(--border); border-radius: 50%; }
.structure-legend { flex: 0 0 auto; border-collapse: collapse; font-size: 0.72rem; line-height: 1.25; }
.structure-legend th, .structure-legend td { padding: 0.14rem 0.4rem; text-align: left; }
.structure-legend th { font-size: 0.68rem; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); }
.structure-legend td { color: var(--gray-700); }
.structure-legend td:first-child { max-width: 15rem; }
.structure-legend tbody tr { transition: background 0.15s; }
.structure-legend tbody tr.active { background: var(--gray-50); }
.structure-legend .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.structure-swatch { display: inline-block; width: 0.6rem; height: 0.6rem; margin-right: 0.35rem; border-radius: 2px; vertical-align: -1px; }

.finanse-contact { margin: 0 0 0.75rem; font-size: 0.85rem; }
.finanse-hint { margin: 0 0 0.6rem; }
.finanse-stats { grid-template-columns: repeat(auto-fit, minmax(300px, 520px)); }
.finanse-stats .stat-box dl { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin: 0 0 0.75rem; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 0.5rem 0.9rem; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); text-decoration: none; white-space: nowrap; }
.tabs a:hover { color: var(--link-hover); }
.tabs a.active { color: var(--green-800); border-bottom-color: var(--green-600); font-weight: 600; }

/* ---------- Targi: mapa stoisk i formularz ---------- */
.targi-hint { margin: 0 0 0.5rem; font-size: 0.85rem; }
.targi-back { margin-left: auto; font-size: 0.9rem; }
/* Informacja o puli miejsc z wyborem lokalizacji */
.targi-choice { margin: 0 0 0.75rem; padding: 0.55rem 0.8rem; border: 1px solid var(--warn); border-radius: var(--radius); background: var(--warn-bg); font-size: 0.9rem; font-weight: 600; }
.button.targi-back { font-size: inherit; }
.targi-map-wrap { position: relative; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--gray-50); }
.targi-map { display: block; width: 100%; height: auto; min-width: 900px; }
/* Statusy stoisk: wolne zielone, twoje zlote, zajete czerwone (takze zablokowane), wybrane niebieskie. */
.stoisko rect { stroke-width: 1.5; }
.stoisko text { pointer-events: none; font-weight: 600; fill: var(--gray-900); }
.stoisko[data-status="wolne"] rect { fill: #bfe8cf; stroke: #15803d; }
.stoisko[data-status="wolne"] text { fill: #14532d; }
.stoisko[data-status="twoje"] rect { fill: #fcd34d; stroke: #b45309; stroke-width: 2; }
.stoisko[data-status="twoje"] text { fill: #78350f; font-weight: 700; }
.stoisko[data-status="zajete"] rect { fill: #f8c4c4; stroke: #b91c1c; }
.stoisko[data-status="zajete"] text { fill: #7f1d1d; }
.targi-map[data-mode="select"] .stoisko[data-status="wolne"],
.targi-map[data-mode="select"] .stoisko[data-status="twoje"],
.targi-map[data-mode="info"] .stoisko { cursor: pointer; }
.targi-map[data-mode="select"] .stoisko[data-status="wolne"]:hover rect { filter: brightness(0.93); }
.stoisko:focus { outline: none; }
.stoisko:focus-visible rect { stroke: var(--green-800); stroke-width: 2.5; }
.stoisko[data-status="zajete"] { cursor: pointer; } /* klik pokazuje chmurke z firma */
.stoisko.selected rect { fill: #1d4ed8; stroke: #1e3a8a; stroke-width: 2.5; }
.stoisko.selected text { fill: #fff; font-weight: 700; }

/* Chmurka z nazwa firmy nad kliknietym zajetym stoiskiem (public/js/targi.js) */
.targi-tip {
  position: absolute;
  z-index: 5;
  transform: translate(-50%, calc(-100% - 8px));
  max-width: 320px;
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  background: var(--gray-900);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: normal;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.targi-tip::after {
  content: "";
  position: absolute;
  left: calc(50% + var(--arrow-shift, 0px));
  top: 100%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--gray-900);
}
.targi-tip.below { transform: translate(-50%, 8px); }
.targi-tip.below::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--gray-900); }
.targi-tip[hidden] { display: none; }
/* Chmurka wybranego stoiska: dane jak w panelu + zdjecie typu (klikalne) */
.targi-tip.rich {
  width: max-content;
  max-width: min(260px, 80vw);
  padding: 0.6rem 0.75rem;
  background: #fff;
  color: var(--gray-900);
  font-weight: 400;
  text-align: left;
  pointer-events: auto;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.targi-tip.rich::after { border-top-color: #fff; }
.targi-tip.rich.below::after { border-top-color: transparent; border-bottom-color: #fff; }
.targi-tip-title { display: block; margin-bottom: 0.35rem; color: var(--green-900); }
.targi-tip dl { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.75rem; margin: 0; }
.targi-tip dt { color: var(--muted); font-size: 0.8rem; }
.targi-tip dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.targi-tip-photo { display: block; margin-top: 0.5rem; line-height: 0; }
/* Stala wysokosc: chmurka nie zmienia rozmiaru (i polozenia) po doczytaniu zdjecia. */
.targi-tip-photo img { display: block; width: 220px; max-width: 100%; height: 140px; object-fit: contain; border: 1px solid var(--border); border-radius: 4px; background: #fff; }

/* Strefy informacyjne (pod stoiskami, nieklikalne) */
.targi-info { pointer-events: none; }
.targi-info .hala { fill: #fff; stroke: var(--gray-400); stroke-width: 1.5; }
.strefa text { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.strefa-coffee rect { fill: var(--gray-200); stroke: none; }
.strefa-coffee text { fill: var(--gray-500); font-size: 16px; }
.strefa-novelty rect { fill: var(--warn-bg); stroke: var(--warn); stroke-width: 1.2; stroke-dasharray: 6 4; }
.strefa-novelty text { fill: var(--warn); }
.wejscie line { stroke: var(--green-700); stroke-width: 3; }
.targi-map marker path { fill: var(--green-700); }
.wejscie text { fill: var(--green-800); font-size: 13px; font-weight: 700; text-transform: uppercase; }
.targi-zones-info { margin: -0.75rem 0 1.25rem; font-size: 0.85rem; color: var(--muted); }

.targi-legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; list-style: none; margin: 0.5rem 0 1.25rem; padding: 0; font-size: 0.85rem; color: var(--gray-700); }
.targi-legend li { display: flex; align-items: center; gap: 0.4rem; }
.targi-legend .swatch { width: 1rem; height: 0.75rem; border-radius: 2px; border: 1px solid; }
.swatch[data-status="wolne"] { background: #bfe8cf; border-color: #15803d; }
.swatch[data-status="twoje"] { background: #fcd34d; border-color: #b45309; }
.swatch[data-status="zajete"] { background: #f8c4c4; border-color: #b91c1c; }
.swatch[data-status="wybrane"] { background: #1d4ed8; border-color: #1e3a8a; }

.targi-fields { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 1.5rem; border: 0; padding: 0; margin: 0; }
.targi-panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--gray-50); padding: 0.75rem 1rem; margin-bottom: 1rem; }
.targi-panel dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 0.5rem 0.75rem; margin: 0; }
.targi-panel dt { font-size: 0.75rem; color: var(--muted); }
.targi-panel dd { margin: 0.15rem 0 0; font-weight: 650; color: var(--green-900); font-variant-numeric: tabular-nums; }
.targi-panel-info { margin-top: -0.5rem; }
.targi-panel-info dl { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.targi-novelty-hint { margin: 0 0 0.6rem; }
/* Targi - produkty targowe: lista wybranych w formularzu i okno wyboru (public/js/targi.js) */
.targi-trade-table td:first-child { overflow-wrap: anywhere; }
.targi-trade-table .badge { margin-left: 0.25rem; }
.targi-trade-mega { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.targi-trade-hit { background: var(--green-100); color: var(--green-800); font-weight: 600; }
.targi-trade-empty { margin: 0.5rem 0 0; font-size: 0.85rem; }
.targi-trade-empty[hidden] { display: none; }
.targi-trade-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-top: 0.75rem; font-size: 0.85rem; }
.targi-trade-foot button { margin: 0; }
button.targi-trade-remove, button.targi-trade-remove:hover { color: var(--danger); font-size: 0.85rem; }
.targi-trade-modal { width: min(92vw, 720px); padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); }
.targi-trade-modal::backdrop { background: rgba(0, 0, 0, 0.55); }
.targi-trade-modal h2 { margin-top: 0; }
.targi-trade-options { height: min(55vh, 480px); overflow-y: auto; overscroll-behavior: contain; margin: 0.75rem 0; padding: 0 0.75rem 0.5rem; border: 1px solid var(--border); border-radius: var(--radius); }
.targi-trade-group { position: sticky; top: 0; margin: 0 -0.75rem; padding: 0.4rem 0.75rem; background: var(--gray-50); border-bottom: 1px solid var(--border); font-size: 0.8rem; font-weight: 600; color: var(--gray-700); }
.targi-trade-group[hidden] { display: none; }
label.targi-trade-option { margin: 0; padding: 0.35rem 0; border-bottom: 1px solid var(--border); cursor: pointer; }
label.targi-trade-option.chosen { color: var(--muted); cursor: default; }
.targi-trade-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.targi-trade-ean { font-size: 0.8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.targi-trade-modal-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.5rem 0.75rem; }
.targi-trade-modal-foot span { margin-right: auto; font-size: 0.85rem; }
.targi-trade-modal-foot button { margin: 0; }
textarea { resize: vertical; }
input.invalid { border-color: var(--danger); }

.targi-table-wrap { overflow-x: auto; }
.targi-items { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.targi-items th, .targi-items td { padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.targi-items thead th { background: var(--gray-50); font-size: 0.8rem; color: var(--gray-700); font-weight: 600; }
.targi-items .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.targi-items input[type=number] { width: 5.5rem; margin: 0 0 0 auto; padding: 0.35rem 0.5rem; text-align: right; }
.targi-items tr.unavailable td { color: var(--gray-400); }
.targi-items tfoot th, .targi-items tfoot td { border-bottom: 0; padding-top: 0.6rem; font-size: 1rem; }
.targi-items tfoot th { text-align: right; }
.targi-regulations { margin-top: 1rem; }
.targi-submit { margin-top: 0.5rem; }

.targi-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.targi-stats .stat-box dl { grid-template-columns: 1fr; }

@media (max-width: 900px) {
  .targi-fields { grid-template-columns: 1fr; }
}

/* ---------- Tablet ---------- */
@media (max-width: 900px) {
  .topbar { gap: 1rem; padding: 0 var(--gutter); }
  .logout .muted { display: none; }
  .topbar-company { max-width: 12rem; }
}

/* ---------- Telefon ---------- */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .page { margin: 0.75rem auto; }
  .card { padding: 1rem; border-radius: 8px; }
  .card.narrow { margin: 1.5rem auto; }
  h1 { font-size: 1.2rem; }

  /* Pasek gorny w dwoch rzedach: marka + jezyk/wyloguj, pod spodem przewijana nawigacja. */
  .topbar { flex-wrap: wrap; row-gap: 0; padding-top: 0.4rem; }
  .topbar-right { gap: 0.9rem; }
  .topbar-company { max-width: 8rem; font-size: 0.8rem; }
  .topbar nav {
    order: 3;
    flex: 1 0 100%;
    overflow-x: auto;
    margin: 0 calc(-1 * var(--gutter));
    padding: 0.25rem var(--gutter) 0.4rem;
    scrollbar-width: none;
  }
  .topbar nav::-webkit-scrollbar { display: none; }

  .toolbar { gap: 0.6rem; }
  .toolbar .button { margin-left: auto; }
  .search { flex: 1 0 100%; order: 3; margin-left: 0; }
  .report-group { flex: 1 0 100%; }
  .report-updated { margin-left: 0; }
  .stats { grid-template-columns: 1fr; }
  .stat-box dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .structure { flex-direction: column; align-items: stretch; }
  .structure-legend { width: 100%; font-size: 0.78rem; }
  .structure-legend td:first-child { max-width: none; }

  .actions > form, .actions button { flex: 1; }
  .actions button { width: 100%; }
}

/* ---------- Stopka ---------- */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 1.25rem var(--gutter);
  color: var(--muted);
  font-size: 0.9rem;
}
.site-footer img { height: 40px; width: auto; max-width: 100%; }

/* ---------- Pole hasla z oczkiem ---------- */
.pw { position: relative; display: block; margin-top: 0.3rem; }
.pw input { margin-top: 0; padding-right: 2.6rem; }
button.pw-toggle {
  position: absolute;
  top: 50%;
  right: 0.3rem;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  padding: 0.3rem;
  margin: 0;
  background: none;
  border: 0;
  color: var(--muted);
}
button.pw-toggle:hover { background: none; color: var(--link-hover); }

/* Targi - ustawienia (admin): cennik, regulamin */
.targi-settings input[type=text] { width: 8rem; margin: 0 0 0 auto; padding: 0.35rem 0.5rem; text-align: right; }
.targi-settings { margin-bottom: 0.75rem; }
.targi-upload { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-bottom: 0.75rem; }
.targi-upload input[type=file] { max-width: 100%; font-size: 0.9rem; }

/* Targi - podglad (zdjecie) typu stoiska / dodatku w formularzu zgloszenia (public/js/targi.js) */
/* Miniaturka zdjecia - link do podgladu (formularz zgloszenia, cennik, siatka dodatkow). */
.preview-thumb { display: inline-block; vertical-align: middle; margin-right: 0.4rem; line-height: 0; }
.preview-thumb img { display: block; width: 3rem; height: 3rem; object-fit: cover; border: 1px solid var(--border); border-radius: 4px; background: #fff; }
.preview-thumb:hover img { border-color: var(--link); }
.preview-thumb[hidden] { display: none; }
.targi-panel .preview-thumb { margin: 0 0 0 0.4rem; }
.grid-upload .preview-thumb { margin-right: 0; }
.grid-upload .preview-thumb img { width: 2.25rem; height: 2.25rem; }
.targi-preview { max-width: min(92vw, 900px); padding: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); }
.targi-preview::backdrop { background: rgba(0, 0, 0, 0.55); }
.targi-preview img { display: block; max-width: 100%; max-height: 78vh; margin: 0 auto 0.75rem; }
.targi-preview form { display: flex; justify-content: flex-end; margin: 0; }

/* Targi - ustawienia: podglad w tabeli cennika i w siatce dodatkow (kolumna 'upload' w public/js/grid.js) */
.targi-preview-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; }
.targi-preview-cell input[type=file] { width: 14rem; max-width: 100%; margin: 0; font-size: 0.85rem; }
.targi-preview-cell button { margin: 0; padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.grid-upload { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.2rem 0.7rem; }
.grid-upload form { display: inline; margin: 0; }
.grid-upload button.grid-upload-remove, .grid-upload button.grid-upload-remove:hover { color: var(--danger); }
