/* ==========================================================================
   Partner Helpdesk – style (mobile-first)
   Po zmianie zwiększ 'asset_version' w config.php.
   ========================================================================== */

:root {
  --bg: #f4f6fb;
  --bg-accent: #e8eefc;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --surface-3: #eef2f8;
  --text: #0e1525;
  --text-2: #3b4559;
  --muted: #6b7489;
  --border: #e4e8f0;
  --border-strong: #d3d9e4;

  --primary: #2b5fd9;          /* błękit z logo SP PARTNER */
  --primary-2: #4f7ff0;
  --primary-hover: #224fbd;
  --primary-soft: #ebf1fe;
  --primary-text: #ffffff;
  --accent: #e0412f;           /* czerwień z daszka maskotki */

  --success: #0f8a4b;
  --success-soft: #e7f7ee;
  --danger: #cf2f2f;
  --danger-soft: #fdeded;
  --warning: #b8650a;
  --warning-soft: #fff5e6;
  --staff: #7046e5;
  --staff-soft: #f1ecff;

  --radius-lg: 22px;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(14, 21, 37, .05);
  --shadow: 0 1px 2px rgba(14, 21, 37, .04), 0 10px 30px -14px rgba(14, 21, 37, .18);
  --shadow-lg: 0 24px 60px -20px rgba(14, 21, 37, .28);
  --ring: 0 0 0 4px rgba(43, 95, 217, .18);
  --tap: 48px;
  --nav-h: 68px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --bg-accent: #121a33;
    --surface: #121a2e;
    --surface-2: #172036;
    --surface-3: #1d2740;
    --text: #e8ecf6;
    --text-2: #c3cad9;
    --muted: #8d97ad;
    --border: #232d47;
    --border-strong: #2e3a59;
    --primary: #5b8bff;
    --primary-2: #7aa2ff;
    --primary-hover: #7aa2ff;
    --primary-soft: #1a2750;
    --success: #4ade80;
    --success-soft: #0d2a1b;
    --danger: #f87171;
    --danger-soft: #341416;
    --warning: #fbbf24;
    --warning-soft: #33240a;
    --staff: #a78bfa;
    --staff-soft: #261a4d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px -16px rgba(0, 0, 0, .6);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .7);
    --ring: 0 0 0 4px rgba(91, 139, 255, .25);
  }
}

/* --- Podstawy ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 90px; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--text);
  font: 16px/1.55 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  background:
    radial-gradient(1200px 500px at 100% -10%, var(--bg-accent), transparent 60%),
    radial-gradient(900px 420px at -10% -5%, var(--bg-accent), transparent 55%),
    var(--bg);
  background-attachment: fixed;
}
a { color: var(--primary); text-underline-offset: 3px; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { flex: 0 0 auto; display: block; }
.hp { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }

/* --- Pasek górny ------------------------------------------------------------------ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
}
/* Rozmycie na pseudo-elemencie: backdrop-filter na samym nagłówku „więziłby” dolny pasek (position: fixed). */
.topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
}
.topbar__inner {
  max-width: 1100px;
  margin: 0 auto;
  min-height: 64px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--text); text-decoration: none; margin-right: auto; }
.brand__logo { height: 38px; width: auto; display: block; }
.brand__name { font-weight: 800; letter-spacing: -.01em; }
.brand__tag {
  display: none;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
}
.topbar__user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar__user form { margin: 0; }
.topbar__who { display: none; flex-direction: column; line-height: 1.2; min-width: 0; }
.topbar__email { font-size: 14px; font-weight: 600; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__company { font-size: 12px; color: var(--muted); }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* Nawigacja: na telefonie dolny pasek jak w aplikacji, na komputerze w nagłówku. */
.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  justify-content: space-around;
  gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--border);
}
.nav__link {
  flex: 1 0 62px;
  min-width: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  padding: 4px 2px;
  border-radius: 14px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  transition: color .15s, background-color .15s;
}
.nav__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.nav__link.is-active { color: var(--primary); background: var(--primary-soft); }
.nav__link--cta { color: var(--primary); }
.nav__link--cta .icon {
  width: 30px;
  height: 30px;
  padding: 5px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  color: #fff;
  box-shadow: 0 6px 14px -6px var(--primary);
}
.nav__link--cta.is-active { background: transparent; }


/* Rozwijane menu „Ustawienia” (na telefonie otwiera się w górę nad dolnym paskiem) */
.nav-menu { position: relative; display: flex; flex: 1 0 62px; min-width: 62px; }
.nav-menu > summary { list-style: none; cursor: pointer; width: 100%; user-select: none; }
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-menu[open] > summary { color: var(--primary); background: var(--primary-soft); }
.nav-menu__caret { display: none; transition: transform .2s; }
.nav-menu[open] .nav-menu__caret { transform: rotate(180deg); }
.nav-menu__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  z-index: 60;
  min-width: 230px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  animation: menu-in .14s ease-out;
}
@keyframes menu-down { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes menu-in { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.nav-menu__item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
}
.nav-menu__item .icon { color: var(--muted); }
.nav-menu__item:hover { background: var(--surface-3); }
.nav-menu__item.is-active { background: var(--primary-soft); color: var(--primary); }
.nav-menu__item.is-active .icon { color: var(--primary); }

/* --- Układ ------------------------------------------------------------------------ */
.container {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 18px 14px 40px;
}
.is-auth .container { padding-bottom: calc(var(--nav-h) + 40px + env(safe-area-inset-bottom)); }
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 0 16px 24px;
}
.is-auth .container { padding-bottom: 24px; }
.is-auth .footer { padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }

.page-head { margin: 4px 0 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; justify-content: space-between; }
.page-head--ticket { display: block; }
.page-head p { margin: 2px 0 0; flex-basis: 100%; }
.page-title { margin: 0; font-size: 24px; line-height: 1.2; font-weight: 800; letter-spacing: -.02em; word-break: break-word; }
.page-title .muted { font-weight: 600; }
.section-title { font-size: 15px; font-weight: 700; color: var(--text-2); margin: 26px 0 10px; text-transform: uppercase; letter-spacing: .04em; }
.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  margin-bottom: 4px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}
.back:hover { color: var(--primary); }
.meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}
.card__title { margin: 0 0 14px; font-size: 16px; font-weight: 700; }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.form-card > summary { margin: 0; min-height: 28px; display: flex; align-items: center; color: var(--primary); }
details.form-card[open] > summary { margin-bottom: 14px; }

/* --- Awatary ------------------------------------------------------------------------- */
.avatar {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .02em;
  user-select: none;
}
.avatar--xs { width: 22px; height: 22px; font-size: 10px; }
.avatar--c0 { background: linear-gradient(135deg, #5b8bff, #2b5fd9); }
.avatar--c1 { background: linear-gradient(135deg, #34d399, #059669); }
.avatar--c2 { background: linear-gradient(135deg, #f472b6, #db2777); }
.avatar--c3 { background: linear-gradient(135deg, #fbbf24, #d97706); }
.avatar--c4 { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.avatar--c5 { background: linear-gradient(135deg, #22d3ee, #0891b2); }
.avatar--c6 { background: linear-gradient(135deg, #fb7185, #e11d48); }
.avatar--c7 { background: linear-gradient(135deg, #94a3b8, #475569); }
.avatar--staff { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--staff); }

/* --- Komunikaty -------------------------------------------------------------------------- */
.alert {
  position: relative;
  border-radius: var(--radius);
  padding: 12px 14px 12px 16px;
  margin-bottom: 14px;
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 500;
  word-break: break-word;
}
.alert::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: currentColor; }
.alert--success { background: var(--success-soft); color: var(--success); }
.alert--error   { background: var(--danger-soft);  color: var(--danger); }
.alert--warning { background: var(--warning-soft); color: var(--warning); }
.alert--info    { background: var(--primary-soft); color: var(--primary); }
.notice { color: var(--muted); font-size: 14px; text-align: center; margin: 6px 0 14px; }
.debug { white-space: pre-wrap; text-align: left; font-size: 12px; background: var(--surface-2); padding: 12px; border-radius: 10px; overflow: auto; }
.debug-code { font: 800 24px/1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: 5px; margin-left: 6px; }

/* --- Przyciski -------------------------------------------------------------------------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 14px;
  font: 600 15px/1.2 var(--font);
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  white-space: nowrap;
  transition: transform .12s, box-shadow .15s, background-color .15s, border-color .15s, opacity .15s;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .65; cursor: not-allowed; }
.btn--primary {
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  color: var(--primary-text);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 8px 20px -10px var(--primary);
}
.btn--primary:hover:not(:disabled) { box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 12px 26px -10px var(--primary); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn--secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn--ghost { background: transparent; color: var(--primary); border-color: var(--border); }
.btn--ghost:hover:not(:disabled) { background: var(--primary-soft); border-color: transparent; }
.btn--danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn--danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn--sm { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn--lg { min-height: 54px; font-size: 16px; border-radius: 16px; }
.btn--block { display: flex; width: 100%; }

/* Stan „wysyłanie…” – kręciołek zamiast treści przycisku */
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.btn--secondary.is-loading::after, .btn--ghost.is-loading::after, .btn--danger.is-loading::after {
  border-color: color-mix(in srgb, var(--primary) 30%, transparent);
  border-top-color: var(--primary);
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn:focus-visible, .input:focus-visible, .nav__link:focus-visible, .icon-btn:focus-visible, a:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* --- Formularze ------------------------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: 16px; margin: 0; }
.form--secondary { margin-top: 10px; }
.field { display: flex; flex-direction: column; gap: 7px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field__label { font-weight: 600; font-size: 14px; color: var(--text-2); padding: 0; }
.field-row { display: grid; gap: 16px; }
.input {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font: 16px/1.4 var(--font); /* 16px = brak auto-zoomu na iOS */
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.input::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
.input:hover { border-color: var(--border-strong); }
.input:focus { outline: none; background: var(--surface); border-color: var(--primary); box-shadow: var(--ring); }
select.input {
  padding-right: 42px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 21px) 52%, calc(100% - 15px) 52%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}
textarea.input { min-height: 110px; resize: vertical; line-height: 1.55; }
.input--lg { min-height: 56px; font-size: 17px; }
.input--code {
  min-height: 68px;
  text-align: center;
  font: 800 32px/1 ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 12px;
  padding-left: 24px;
}
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 12px; min-height: var(--tap); cursor: pointer; font-weight: 500; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); }

/* Wyszukiwarka z ikoną */
.search { position: relative; display: block; }
.search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { padding-left: 42px; }

/* Kafelki wyboru podkategorii */
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice__box {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 60px;
  height: 100%;
  padding: 12px 10px;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  background: var(--surface-2);
  font-weight: 600;
  font-size: 14px;
  line-height: 1.25;
  transition: border-color .15s, background-color .15s, box-shadow .15s, transform .1s;
}
.choice:active .choice__box { transform: scale(.98); }
.choice input:checked + .choice__box {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}
.choice input:focus-visible + .choice__box { box-shadow: var(--ring); }

/* Podkategorie z opisem: nazwa + drobny opis pod spodem */
.choice-grid--cats { grid-template-columns: 1fr; }
.choice--cat .choice__box {
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  text-align: left;
  gap: 4px;
  padding: 12px 14px;
}
.choice__title { font-weight: 650; font-size: 14.5px; }
.choice__desc { font-weight: 400; font-size: 12px; line-height: 1.4; color: var(--muted); }
.choice input:checked + .choice__box .choice__desc { color: color-mix(in srgb, var(--primary) 70%, var(--muted)); }

/* --- Wybór plików ------------------------------------------------------------------------ */
.file-picker { display: flex; flex-direction: column; gap: 10px; }
.file-picker__btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 64px;
  padding: 14px 16px;
  border: 1.5px dashed color-mix(in srgb, var(--primary) 40%, var(--border));
  border-radius: 18px;
  background: color-mix(in srgb, var(--primary-soft) 70%, var(--surface));
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color .15s, border-color .15s;
}
.file-picker__btn:hover, .file-picker__btn.is-dragover { border-style: solid; background: var(--primary-soft); }
.file-picker__btn:active { transform: scale(.99); }
/* Input zakrywa cały przycisk – niezawodne otwieranie wyboru plików na iOS i Androidzie. */
.file-picker__input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }
.file-picker__icon {
  display: inline-flex;
  padding: 7px;
  border-radius: 11px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.file-picker__hint { margin: 0; font-size: 13px; color: var(--muted); }

.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}
.file-item--error { border-color: var(--danger); background: var(--danger-soft); }
.file-item__thumb, .file-item__icon { flex: 0 0 48px; width: 48px; height: 48px; border-radius: 10px; object-fit: cover; }
.file-item__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
  font: 800 11px/1 var(--font);
}
.file-item__meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-item__name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item__size { font-size: 12px; color: var(--muted); }
.file-item__remove {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.file-item__remove:hover { background: var(--danger-soft); color: var(--danger); }

.progress { display: flex; flex-direction: column; gap: 6px; }
.progress__track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress__bar { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--primary-2), var(--primary)); transition: width .2s; }
.progress__label { font-size: 13px; color: var(--muted); text-align: center; }

/* --- Logowanie ---------------------------------------------------------------------------- */
body:has(.auth) .topbar { display: none; }
.auth { display: flex; justify-content: center; align-items: center; min-height: calc(100vh - 120px); padding: 4vh 0; }
.auth__card {
  width: 100%;
  max-width: 420px;
  padding: 30px 22px 24px;
  border-radius: 26px;
  box-shadow: var(--shadow-lg);
}
.auth__logo { display: block; height: 52px; width: auto; margin: 0 auto 6px; }
.auth__kicker {
  margin: 0 0 22px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.auth__title { margin: 0 0 6px; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.auth .muted { margin: 0 0 20px; }

/* --- Zakładki i filtry -------------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin: 0 -14px 14px;
  padding: 2px 14px 4px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs__item {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
  transition: background-color .15s, color .15s, border-color .15s;
}
.tabs__item:hover { border-color: var(--border-strong); }
.tabs__item.is-active { background: var(--text); border-color: var(--text); color: var(--surface); }
.tabs__count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  text-align: center;
}
.tabs__item.is-active .tabs__count { background: color-mix(in srgb, var(--surface) 20%, transparent); color: var(--surface); }
.filters { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 16px; }
.filters select { grid-column: 1 / -1; }

/* --- Lista zgłoszeń ---------------------------------------------------------------------- */
.ticket-list, .list { list-style: none; margin: 0; padding: 0; }
.ticket-list { display: grid; gap: 10px; }
.ticket-card {
  position: relative;
  display: block;
  padding: 16px 18px 14px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.ticket-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: transparent; }
.ticket-card.is-attention::before { background: linear-gradient(180deg, var(--primary-2), var(--primary)); }
.ticket-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--primary) 25%, var(--border)); }
.ticket-card:active { transform: scale(.995); }
.ticket-card__top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13px; }
.ticket-card__id { color: var(--muted); font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.ticket-card__time { margin-left: auto; color: var(--muted); font-size: 12px; }
.ticket-card__subject { margin: 8px 0 10px; font-size: 17px; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; word-break: break-word; }
.ticket-card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.ticket-card__company { font-weight: 700; color: var(--text-2); }
.ticket-card__author { display: inline-flex; align-items: center; gap: 6px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}
.badge--open { background: var(--success-soft); color: var(--success); }
.badge--open::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--closed { background: var(--surface-3); color: var(--muted); }
.badge--attention { background: linear-gradient(135deg, var(--primary-2), var(--primary)); color: #fff; }
.badge--staff { background: var(--staff-soft); color: var(--staff); }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}

.empty { text-align: center; padding: 36px 18px; }
.empty__title { font-weight: 800; font-size: 18px; margin: 0 0 4px; }
.empty__code {
  font-size: 56px;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 10px;
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.pagination { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-top: 18px; }
.pagination > :last-child { justify-self: end; }
.pagination__info { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }

/* --- Szczegóły zgłoszenia ------------------------------------------------------------------- */
.ticket-info { padding: 14px 18px; }
.ticket-info > summary { font-weight: 700; min-height: 30px; display: flex; align-items: center; }
.ticket-info > summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; }
.ticket-info[open] > summary::after { transform: rotate(-135deg); }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 14px 0 0; font-size: 15px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; word-break: break-word; }
.ticket-info__actions { margin-top: 16px; }

/* --- Wątek (czat) --------------------------------------------------------------------------- */
.thread { display: flex; flex-direction: column; gap: 14px; margin: 18px 0; }
.msg-row { display: flex; align-items: flex-end; gap: 8px; }
.msg-row--mine { flex-direction: row-reverse; }
.msg-row__avatar { width: 32px; height: 32px; font-size: 12px; margin-bottom: 2px; }
.msg {
  max-width: 86%;
  min-width: 0;
  padding: 10px 14px 12px;
  border-radius: 20px 20px 20px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  scroll-margin-top: 110px;
}
.msg--mine {
  border-radius: 20px 20px 6px 20px;
  background: linear-gradient(160deg, var(--primary-2), var(--primary));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 10px 24px -14px var(--primary);
}
.msg--theirs.msg--staff { border-color: color-mix(in srgb, var(--staff) 30%, var(--border)); }
.msg:target { box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 30%, transparent); }
.msg__head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; margin-bottom: 4px; }
.msg__author { font-weight: 700; }
.msg__time { opacity: .7; }
.msg--mine .msg__head { justify-content: flex-end; }
.msg--mine .badge--staff { background: rgba(255, 255, 255, .2); color: #fff; }
.msg__body { word-break: break-word; overflow-wrap: anywhere; font-size: 15.5px; line-height: 1.5; }
.msg--mine .msg__body a { color: #fff; }
.msg__images { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; margin-top: 10px; }
.thumb { display: block; aspect-ratio: 1 / 1; border-radius: 12px; overflow: hidden; background: rgba(0, 0, 0, .06); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.thumb:hover img { transform: scale(1.04); }
.msg__files { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 6px 12px 6px 6px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
}
.file-row:hover { border-color: var(--border-strong); }
.msg--mine .file-row { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .22); }
.file-row__badge {
  flex: 0 0 auto;
  min-width: 40px;
  padding: 8px 6px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font: 800 10px/1 var(--font);
  text-align: center;
}
.msg--mine .file-row__badge { background: rgba(255, 255, 255, .25); color: #fff; }
.file-row__name { flex: 1; min-width: 0; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row__size { font-size: 12px; opacity: .75; white-space: nowrap; }
.file-row__dl { font-weight: 700; }

.reply { position: relative; }

/* --- Listy w panelu admina ---------------------------------------------------------------- */
.list { display: grid; gap: 10px; }
.list > .card { margin-bottom: 0; }
.list-item { display: flex; flex-direction: column; gap: 12px; }
.list-item--stack { gap: 4px; }
.list-item.is-inactive { opacity: .65; }
.list-item__main { min-width: 0; }
.list-item__title { font-weight: 700; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; word-break: break-all; }
.list-item__meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); margin-top: 4px; }
.list-item__meta a { text-decoration: none; }
.list-item form { margin: 0; }
.edit > summary { list-style: none; width: fit-content; }
.edit > summary::-webkit-details-marker { display: none; }
.edit[open] > summary { margin-bottom: 14px; }
.danger-zone { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border-strong); gap: 10px; }
.danger-zone__text { margin: 0; font-size: 14px; }
.audit__details { font-size: 14px; color: var(--text-2); word-break: break-word; }

/* --- Statusy i priorytety ------------------------------------------------------------------ */
.badge--in-progress { background: #fff4e0; color: #b45309; }
.badge--scheduled { background: #e8f0ff; color: #2b5fd9; }
.badge--visit { background: #f1ecff; color: #6d3fe0; }
.badge--ordering { background: #e6f6fb; color: #0e7490; }
.badge--waiting-parts { background: #fdf2e9; color: #c2410c; }
.badge--resolved { background: #e7f8ee; color: #15803d; }
.badge--cancelled { background: var(--surface-3); color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.badge--needs-reply { background: #fde8ec; color: #be123c; font-weight: 700; }
.badge--in-progress::before, .badge--scheduled::before, .badge--visit::before,
.badge--ordering::before, .badge--waiting-parts::before, .badge--resolved::before, .badge--needs-reply::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
@media (prefers-color-scheme: dark) {
  .badge--in-progress { background: #3a2a0c; color: #fbbf24; }
  .badge--scheduled { background: #18275a; color: #8fb0ff; }
  .badge--visit { background: #2a1a55; color: #b9a2ff; }
  .badge--ordering { background: #0f3340; color: #67d4ec; }
  .badge--waiting-parts { background: #3d2010; color: #fb9a5b; }
  .badge--resolved { background: #0f3320; color: #6ee7a0; }
  .badge--needs-reply { background: #45121f; color: #fb7f99; }
}
.badge--prio { background: transparent; border: 1px solid var(--border); color: var(--text-2); font-weight: 600; }
.badge--prio-high { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); color: var(--danger); }
.prio-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.prio-dot--high { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }
.prio-dot--medium { background: #f59e0b; }
.prio-dot--low { background: #94a3b8; }
.choice-grid--3 { grid-template-columns: repeat(3, 1fr); }
.choice__box .prio-dot { margin-right: 8px; }

.ticket-card__when {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: -2px 0 10px;
  padding: 4px 10px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

/* Karta terminu w zgłoszeniu */
.schedule-card { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px; border-color: color-mix(in srgb, var(--primary) 25%, var(--border)); }
.schedule-card__icon {
  display: flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary-2), var(--primary)); color: #fff;
  box-shadow: 0 8px 20px -10px var(--primary);
}
.schedule-card__main { flex: 1 1 160px; min-width: 0; }
.schedule-card__label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.schedule-card__when { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.schedule-card__actions { display: flex; flex-wrap: wrap; gap: 8px; }

.schedule-fields { border: 1px dashed var(--border-strong); border-radius: 16px; padding: 12px 14px 14px; margin: 0; }
.schedule-fields legend { padding: 0 6px; }
.schedule-fields__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.schedule-fields__grid .field:first-child { grid-column: 1 / -1; }
.field__hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.schedule-fields__grid .field__hint { margin: 0; }

/* --- Kalendarz ---------------------------------------------------------------------------- */
.cal { padding: 14px; }
.cal__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cal__title { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.cal__tools { display: flex; justify-content: center; gap: 8px; margin: 10px 0 12px; flex-wrap: wrap; }
.cal__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal__wd { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; padding: 4px 0; }
.cal__day {
  min-height: 48px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  overflow: hidden;
}
.cal__day.is-weekend { background: var(--surface-3); }
.cal__day.is-out { opacity: .4; }
.cal__num { font-size: 13px; font-weight: 700; color: var(--text-2); text-decoration: none; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.cal__day.is-today .cal__num { background: var(--primary); color: #fff; }
.cal__day.has-events .cal__num:not(:only-child) { }
/* Na telefonie wydarzenia jako kropki – szczegóły w liście pod kalendarzem */
.cal__ev { display: block; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); text-decoration: none; overflow: hidden; }
.cal__ev-time, .cal__ev-text { display: none; }
.cal__ev--visit { background: #7c4df0; }
.cal__ev--closed { background: #94a3b8; }
.cal__ev--in-progress, .cal__ev--open { background: #f59e0b; }
.cal__legend { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 12px; font-size: 13px; color: var(--muted); }
.cal__legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal__dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.cal__dot--scheduled { background: var(--primary); }
.cal__dot--visit { background: #7c4df0; }
.cal__dot--closed { background: #94a3b8; }

.agenda__day { display: flex; align-items: baseline; gap: 10px; margin: 18px 4px 8px; font-size: 15px; }
.agenda__day.is-today .agenda__date { color: var(--primary); }
.agenda__date { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.agenda__wd { color: var(--muted); font-weight: 600; text-transform: capitalize; }
.agenda__list { margin-bottom: 4px; }
.agenda__item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin: 0;
  padding: 14px 16px;
  color: var(--text);
  text-decoration: none;
  transition: transform .15s, box-shadow .15s;
}
.agenda__item:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.agenda__time { flex: 0 0 74px; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; line-height: 1.3; }
.agenda__time small { color: var(--muted); font-weight: 600; }
.agenda__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.agenda__title { font-weight: 700; word-break: break-word; }
.agenda__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; color: var(--muted); }

.subscribe { margin-top: 24px; }
.subscribe .card__title { display: flex; align-items: center; gap: 8px; }
.subscribe__buttons { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 16px; }
.subscribe__help { padding-left: 18px; font-size: 14px; margin: 14px 0; }
.subscribe__help li + li { margin-top: 6px; }
.copy-field { display: flex; gap: 8px; }
.copy-field .input { flex: 1; min-width: 0; font-size: 13px; }

/* --- Większe ekrany ------------------------------------------------------------------------ */
@media (min-width: 760px) {
  .brand__tag { display: inline-flex; }
  .topbar__who { display: flex; }
  .container { padding: 28px 24px 56px; }
  .is-auth .container { padding-bottom: 56px; }
  .is-auth .footer { padding-bottom: 24px; margin-top: 0; }

  .nav {
    position: static;
    padding: 0;
    gap: 4px;
    background: none;
    border: 0;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .nav__link {
    flex: 0 0 auto;
    flex-direction: row;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 12px;
    font-size: 14px;
  }
  .nav__link { min-width: 0; }
  .nav-menu { flex: 0 0 auto; min-width: 0; }
  .nav-menu__caret { display: inline-flex; margin-left: -2px; }
  .nav-menu__panel { top: calc(100% + 10px); bottom: auto; animation-name: menu-down; }
  .nav__link:hover { color: var(--text); background: var(--surface-3); }
  .nav__link .icon { width: 18px; height: 18px; }
  .nav__link--cta {
    margin-left: 6px;
    color: #fff;
    background: linear-gradient(180deg, var(--primary-2), var(--primary));
    box-shadow: 0 8px 20px -10px var(--primary);
  }
  .nav__link--cta:hover, .nav__link--cta.is-active { color: #fff; background: linear-gradient(180deg, var(--primary-2), var(--primary-hover)); }
  .nav__link--cta .icon { width: 18px; height: 18px; padding: 0; background: none; box-shadow: none; }

  .page-title { font-size: 28px; }
  .choice-grid { grid-template-columns: repeat(3, 1fr); }
  .choice-grid--cats { grid-template-columns: 1fr 1fr; }
  .field-row { grid-template-columns: 1fr 1fr; }
  .filters { display: flex; flex-wrap: wrap; }
  .filters .search { flex: 1 1 260px; }
  .filters select { flex: 0 1 210px; width: auto; }

  /* Kalendarz – pełne nazwy wydarzeń w komórkach */
  .cal { padding: 20px; }
  .cal__day { min-height: 104px; align-items: stretch; padding: 6px; }
  .cal__num { align-self: flex-end; }
  .cal__ev {
    width: auto;
    height: auto;
    border-radius: 7px;
    padding: 3px 6px;
    font-size: 11.5px;
    line-height: 1.25;
    color: #fff;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .cal__ev-time { display: inline; font-weight: 700; margin-right: 4px; opacity: .9; }
  .cal__ev-text { display: inline; }
  .cal__ev--prio-high { box-shadow: inset 3px 0 0 var(--accent); }
  .card { padding: 22px; }
  .msg { max-width: 74%; }
  .msg__images { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .list-item { flex-direction: row; align-items: flex-start; justify-content: space-between; }
  .list-item--stack { flex-direction: column; }
  .list-item:has(.edit[open]) { flex-direction: column; }
  .reply .btn--block { width: auto; align-self: flex-end; min-width: 220px; }
}

/* Średnie ekrany: w menu admina same ikony (podpis w dymku), żeby wszystko się zmieściło */
@media (min-width: 760px) and (max-width: 1239px) {
  .nav--many .nav__label { display: none; }
  .nav--many .nav__link { padding: 0 11px; }
  .nav--many ~ .topbar__user .topbar__who { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: 1.5s !important; }
}

/* --- Import użytkowników z CSV ------------------------------------------------ */
.file-picker__btn--single { margin-top: 2px; }
.import-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 18px; }
.import-stat { padding: 12px; border-radius: 14px; background: var(--surface-2); text-align: center; }
.import-stat strong { display: block; font-size: 24px; font-weight: 800; line-height: 1.1; }
.import-stat span { font-size: 12px; color: var(--muted); }
.import-stat--new strong { color: var(--success); }
.import-stat--update strong { color: var(--primary); }
.mapping { border: 1px dashed var(--border-strong); border-radius: 14px; padding: 10px 14px; }
.mapping > summary { cursor: pointer; }
.mapping[open] > summary { margin-bottom: 10px; }
.mapping__grid { display: grid; gap: 10px; }
.import-list { gap: 6px; }
.import-row { padding: 12px 14px; }
.import-row--skip_exists, .import-row--skip_other_company, .import-row--duplicate { opacity: .65; }
.import-row--invalid { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.import-badge--new { background: var(--success-soft); color: var(--success); }
.import-badge--update { background: var(--primary-soft); color: var(--primary); }
.import-badge--invalid { background: var(--danger-soft); color: var(--danger); }
.import-note { color: var(--warning); font-weight: 600; }
.import-actions { display: grid; gap: 8px; margin-top: 16px; }
.import-actions form { margin: 0; }
@media (min-width: 760px) {
  .mapping__grid { grid-template-columns: repeat(3, 1fr); }
  .import-actions { grid-template-columns: 1fr auto; align-items: center; }
}

/* --- Etykiety ----------------------------------------------------------------- */
.tag { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.tag--blue   { background: #e5edff; color: #2448b8; }
.tag--green  { background: #e3f7ea; color: #13703d; }
.tag--orange { background: #fff0dc; color: #a65200; }
.tag--red    { background: #fde6e6; color: #b42323; }
.tag--purple { background: #efe8ff; color: #5b36c9; }
.tag--pink   { background: #fde7f3; color: #b0246c; }
.tag--teal   { background: #dff6f5; color: #0e6e6b; }
.tag--gray   { background: var(--surface-3); color: var(--text-2); }
@media (prefers-color-scheme: dark) {
  .tag--blue { background: #1c2b5c; color: #a9c0ff; } .tag--green { background: #10331f; color: #7ee2a3; }
  .tag--orange { background: #3d2709; color: #ffc27a; } .tag--red { background: #3d1414; color: #ff9d9d; }
  .tag--purple { background: #2a1d57; color: #c5b2ff; } .tag--pink { background: #3d1530; color: #ff9fd0; }
  .tag--teal { background: #0f3534; color: #79e0db; }
}
.tag-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-option { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px 6px 8px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; background: var(--surface); }
.tag-option input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }
.tag-option:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud a { text-decoration: none; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.admin-block { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border-strong); display: flex; flex-direction: column; gap: 10px; }
.admin-block > summary { cursor: pointer; display: flex; align-items: center; gap: 6px; list-style: none; }
.admin-block > summary::-webkit-details-marker { display: none; }
.admin-block .field__label, .admin-block > summary { display: inline-flex; align-items: center; gap: 6px; }

/* --- Notatki wewnętrzne ---------------------------------------------------------- */
.msg--note {
  background: repeating-linear-gradient(135deg, #fff9e6, #fff9e6 12px, #fff4d1 12px, #fff4d1 24px);
  border: 1px dashed #e0b13d;
  color: #4a3a0e;
  border-radius: 16px;
}
@media (prefers-color-scheme: dark) {
  .msg--note { background: repeating-linear-gradient(135deg, #2e2508, #2e2508 12px, #352b0b 12px, #352b0b 24px); border-color: #8a6d1d; color: #f3e2b0; }
}
.badge--note { background: #ffe8a3; color: #6b4e00; gap: 4px; }
.badge--source { background: var(--surface-3); color: var(--muted); }
.msg--mine .badge--source { background: rgba(255,255,255,.2); color: #fff; }
.check--note { padding: 8px 12px; border-radius: 12px; background: #fff9e6; border: 1px dashed #e0b13d; color: #6b4e00; }
.check--note .icon { display: inline-block; vertical-align: -3px; }
@media (prefers-color-scheme: dark) { .check--note { background: #2e2508; border-color: #8a6d1d; color: #f3e2b0; } }
.reply.is-note { border-color: #e0b13d; box-shadow: 0 0 0 3px rgba(224, 177, 61, .18); }
.reply.is-note .btn--primary { background: linear-gradient(180deg, #f0c24b, #d9a21c); color: #3b2b00; box-shadow: 0 8px 20px -10px #d9a21c; }

/* --- Pulpit -------------------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 8px; }
.stat { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 16px; text-decoration: none; color: var(--text); transition: transform .15s, box-shadow .15s; }
a.stat:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.stat__value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.stat__label { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat--accent .stat__value { color: var(--primary); }
.stat--danger .stat__value { color: var(--danger); }
.dash-grid { display: grid; gap: 4px; }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar { display: grid; grid-template-columns: minmax(0, 1fr) 2fr auto; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-size: 14px; }
.bar__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.bar__track { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar__fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary-2), var(--primary)); }
.bar__fill--w0 { width: 4%; } .bar__fill--w1 { width: 10%; } .bar__fill--w2 { width: 20%; } .bar__fill--w3 { width: 30%; }
.bar__fill--w4 { width: 40%; } .bar__fill--w5 { width: 50%; } .bar__fill--w6 { width: 60%; } .bar__fill--w7 { width: 70%; }
.bar__fill--w8 { width: 80%; } .bar__fill--w9 { width: 90%; } .bar__fill--w10 { width: 100%; }
.bar__value { font-weight: 800; font-variant-numeric: tabular-nums; }

/* --- Konfiguracja ---------------------------------------------------------------------- */
.inline-form--wrap { flex-wrap: wrap; }
.inline-form--wrap .input { flex: 1 1 200px; }
.input--auto { flex: 0 1 180px !important; width: auto; }
.input--narrow { max-width: 160px; }
.card__title--spaced { margin-top: 18px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 6px; }
.btn-row form { margin: 0; }
.canned-preview { display: block; }
code { font: 13px ui-monospace, Menlo, Consolas, monospace; background: var(--surface-3); padding: 1px 6px; border-radius: 6px; }

@media (min-width: 760px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .dash-grid { grid-template-columns: 1fr 1fr; gap: 24px; }
}

/* --- PWA: opcja instalacji i instrukcja dla iPhone'a --------------------------------- */
button.nav-menu__item { width: 100%; border: 0; background: none; font: inherit; font-weight: 600; font-size: 15px; text-align: left; cursor: pointer; }
.nav-menu__item--install { border-top: 1px solid var(--border); border-radius: 0 0 12px 12px; margin-top: 4px; color: var(--primary); }
.nav-menu__item--install .icon { color: var(--primary); }
.footer__install {
  display: inline-flex; align-items: center; gap: 6px; margin-left: 10px; padding: 4px 10px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted);
  font: 600 12px/1.4 var(--font); cursor: pointer;
}
.footer__install:hover { color: var(--primary); border-color: var(--primary); }
.footer__install[hidden] { display: none !important; }
.pwa-sheet { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.pwa-sheet__backdrop { position: absolute; inset: 0; background: rgba(14, 21, 37, .45); animation: fade-in .2s ease-out; }
.pwa-sheet__panel {
  position: relative; width: 100%; max-width: 440px; margin: 0 8px calc(8px + env(safe-area-inset-bottom));
  padding: 26px 22px 22px; background: var(--surface); border-radius: 24px; box-shadow: var(--shadow-lg);
  text-align: center; animation: sheet-up .25s ease-out;
}
.pwa-sheet__close { position: absolute; top: 10px; right: 12px; width: 40px; height: 40px; border: 0; border-radius: 12px; background: var(--surface-3); color: var(--text-2); font-size: 24px; line-height: 1; cursor: pointer; }
.pwa-sheet__icon { width: 64px; height: 64px; border-radius: 16px; box-shadow: var(--shadow); }
.pwa-sheet__title { margin: 14px 0 12px; font-size: 19px; font-weight: 800; }
.pwa-sheet__steps { margin: 0 0 14px; padding: 0 0 0 22px; text-align: left; display: flex; flex-direction: column; gap: 10px; }
.pwa-sheet__key { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); font-weight: 700; white-space: nowrap; }
.pwa-sheet__key .icon { display: inline-block; }
.pwa-sheet__note { margin: 0; font-size: 13px; color: var(--muted); }
@keyframes sheet-up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 760px) { .pwa-sheet { align-items: center; } }
/* Uruchomione jako aplikacja – bez stopki z odnośnikiem instalacji */
.is-standalone .footer__install { display: none !important; }

/* --- Wybór klienta przy nowym zgłoszeniu (admin) ----------------------------------- */
.client-picker { display: grid; gap: 14px; padding: 14px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--border); }
.client-picker .input { background: var(--surface); }
.client-picker__search { margin-bottom: 6px; }
.client-picker select:disabled { opacity: .6; }
@media (min-width: 760px) { .client-picker { grid-template-columns: 1fr 1fr; align-items: start; } }

/* --- Rozdzielanie zgłoszenia ---------------------------------------------------------------- */
.split-list { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow-y: auto; padding: 2px; }
.split-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2); cursor: pointer;
}
.split-item input { margin-top: 3px; flex: none; accent-color: var(--primary); }
.split-item:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.split-item__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.split-item__meta { font-size: 12px; color: var(--muted); }
.split-item__text { font-size: 13.5px; line-height: 1.4; overflow-wrap: anywhere; }

/* --- Import: plik CSV albo lista wpisana ręcznie ------------------------------------------ */
.import-or { display: flex; align-items: center; gap: 12px; margin: 18px 0 10px; color: var(--muted); font-size: 13px; }
.import-or::before, .import-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.import-paste > summary { cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 6px 0; }
.import-paste[open] > summary { margin-bottom: 10px; }
.import-paste textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; }

/* --- Osoby w zgłoszeniu ----------------------------------------------------------------------- */
.participants-pick { margin: 0; padding: 0; border: 0; min-width: 0; }
.participants-pick__list { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; padding: 2px; }
.participants-pick__item { padding: 6px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); }
.participants-pick__item:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.participants-pick__item[hidden] { display: none; }
.participants-pick--js .participants-pick__company { display: none; }
.people-list { display: flex; flex-wrap: wrap; gap: 6px; }
.person-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; }
.person-chip__avatar { width: 22px; height: 22px; font-size: 10px; }

/* --- Opis statusu, „Wymaga Twojej odpowiedzi”, potwierdzenie realizacji ---------------------- */
.status-desc { margin: -6px 0 14px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.needs-reply { display: flex; gap: 14px; align-items: flex-start; border-color: color-mix(in srgb, #e11d48 35%, var(--border)); background: color-mix(in srgb, #e11d48 7%, var(--surface)); }
.needs-reply__icon { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: #e11d48; color: #fff; font-weight: 800; }
.needs-reply p { margin: 4px 0 10px; font-size: 14px; color: var(--text-2); }
.confirm-card { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; border-color: color-mix(in srgb, var(--success) 35%, var(--border)); background: color-mix(in srgb, var(--success) 7%, var(--surface)); }
.confirm-card p { margin: 4px 0 0; font-size: 14px; }
.check--needs-reply { align-items: flex-start; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); }
.check--needs-reply:has(input:checked) { border-color: #e11d48; background: color-mix(in srgb, #e11d48 7%, var(--surface)); }
.check--needs-reply small { display: block; margin-top: 2px; font-weight: 400; }

/* --- Poczta przychodząca ---------------------------------------------------------------------- */
.inbound-row { color: inherit; text-decoration: none; }
.inbound-row:hover { border-color: var(--border-strong); }
.inbound-text { max-height: 420px; overflow-y: auto; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.inbound-full { margin-top: 12px; }
.inbound-full > summary { cursor: pointer; margin-bottom: 8px; }
.inbound-files { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.inbound-files li { display: flex; align-items: center; gap: 8px; }
.inbound-actions .btn-row { margin-top: 14px; }
a.badge--source { text-decoration: none; }
a.badge--source:hover { text-decoration: underline; }

/* --- Asystent AI ------------------------------------------------------------------------------ */
.ai-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 12px;
  border: 1px dashed color-mix(in srgb, var(--primary) 40%, var(--border)); background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
.ai-bar__hint { flex: 1 1 240px; min-width: 0; }
.ai-bar__note { flex: 1 0 100%; margin: 0; }
.ai-bar__note--warn { color: var(--danger, #b42318); font-weight: 600; }

/* --- v10: czas pracy, raporty, terminy, monitoring ------------------------- */
.badge--danger { background: var(--danger-soft); color: var(--danger); font-weight: 700; }
.badge--warn { background: var(--warning-soft); color: var(--warning); font-weight: 700; }
.badge--muted { background: var(--surface-3); color: var(--muted); }
.badge--time { background: var(--surface-3); color: var(--text-2); }
.msg--mine .badge--time { background: rgba(255, 255, 255, .2); color: #fff; }
.text-danger { color: var(--danger); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.row-actions form { margin: 0; }
.row-actions .input--narrow { width: auto; min-width: 0; }
.time-list { list-style: none; margin: 8px 0 12px; padding: 0; display: grid; gap: 6px; }
.time-list__item { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.time-list__min { font-weight: 700; min-width: 72px; }
.time-list__meta { flex: 1; color: var(--muted); min-width: 0; }
.time-list__del { margin: 0; }
.time-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.time-form input[type=date] { grid-column: 1 / -1; }
.time-inline { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.similar-list { margin: 8px 0 10px; padding-left: 18px; display: grid; gap: 4px; font-size: 14px; }
.ai-bar__buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.report-rows { list-style: none; margin: 0 0 8px; padding: 0; }
.report-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.report-row:last-child { border-bottom: 0; }
.report-row .muted { font-size: 13px; flex: 1 1 200px; }
.report-row__time { margin-left: auto; font-weight: 700; white-space: nowrap; }
.report-ticket { padding: 12px 0; border-top: 1px solid var(--border); display: grid; gap: 6px; }
.report-ticket__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.report-ticket__head .muted { font-size: 13px; }
.report-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.deadline-mini { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; font-size: 14px; }
@media (min-width: 640px) {
  .list-item { flex-direction: row; align-items: flex-start; justify-content: space-between; }
  .time-form { grid-template-columns: 1fr 1fr 1fr; }
  .time-form input[type=date] { grid-column: auto; }
}

/* --- abonamenty i stawki ------------------------------------------------------ */
.usage { display: grid; gap: 6px; margin: 4px 0 12px; }
.usage__bar { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.usage__fill { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--primary); transition: width .4s; }
.usage--over .usage__fill { background: var(--danger); }
.usage--over strong { color: var(--danger); }
.usage-card { margin-bottom: 14px; }
.usage-card__label { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.bill-lines { list-style: none; margin: 8px 0 12px; padding: 0; }
.bill-lines li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 14px; }
.bill-lines li .muted { grid-column: 1; font-size: 13px; }
.bill-lines li strong { grid-column: 2; grid-row: 1 / span 2; align-self: center; white-space: nowrap; }
.bill-lines__total { border-top-width: 2px !important; }
.chip--danger { background: var(--danger-soft); color: var(--danger); }
.copy-field textarea { resize: vertical; font-size: 13px; }

/* --- polityka prywatności ---------------------------------------------------- */
.legal { line-height: 1.6; }
.legal h2 { font-size: 16px; margin: 22px 0 8px; }
.legal h2:first-child { margin-top: 0; }
.legal ol, .legal ul { padding-left: 20px; margin: 0 0 10px; display: grid; gap: 6px; }
.legal p { margin: 0 0 10px; }
.footer__link { color: inherit; }
.auth__privacy { margin-top: 14px; text-align: center; }

/* --- zaproszenia ------------------------------------------------------------ */
.invite-preview { display: block; width: 100%; max-width: 360px; height: auto; border-radius: 12px; border: 1px solid var(--border); }

/* --- lokalizacje firm (plakietka jak „● Zaplanowano wizytę”) ------------------ */
.loc { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; line-height: 1.4; vertical-align: middle; }
.loc::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.loc--blue   { background: #e5edff; color: #2448b8; }
.loc--green  { background: #e3f7ea; color: #13703d; }
.loc--orange { background: #fff0dc; color: #a65200; }
.loc--red    { background: #fde6e6; color: #b42323; }
.loc--purple { background: #efe8ff; color: #5b36c9; }
.loc--pink   { background: #fde7f3; color: #b0246c; }
.loc--teal   { background: #dff6f5; color: #0e6e6b; }
.loc--gray   { background: var(--surface-3); color: var(--text-2); }
@media (prefers-color-scheme: dark) {
  .loc--blue { background: #1c2b5c; color: #a9c0ff; } .loc--green { background: #10331f; color: #7ee2a3; }
  .loc--orange { background: #3d2709; color: #ffc27a; } .loc--red { background: #3d1414; color: #ff9d9d; }
  .loc--purple { background: #2a1d57; color: #c5b2ff; } .loc--pink { background: #3d1530; color: #ff9fd0; }
  .loc--teal { background: #0f3534; color: #79e0db; }
}
.list-item__title .loc, dd .loc, .ticket-card__meta .loc, .people-list .loc { margin-left: 4px; }
.loc-list { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.loc-admin { display: grid; gap: 8px; margin-top: 10px; }
.loc-admin__row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; }
.loc-admin__row .input:not(.input--narrow) { flex: 1 1 160px; min-width: 0; }
.loc-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.loc-pick__item { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 8px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; background: var(--surface); }
.loc-pick__item[hidden] { display: none; }

/* --- własne wpisy w kalendarzu -------------------------------------------------- */
.cal__dayhead { display: flex; align-items: center; justify-content: space-between; gap: 2px; width: 100%; }
.cal__add { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 15px; font-weight: 700; line-height: 1; color: var(--muted); text-decoration: none; opacity: 0; transition: opacity .15s, background .15s; }
.cal__day:hover .cal__add, .cal__add:focus-visible { opacity: 1; }
.cal__add:hover { background: var(--primary-soft); color: var(--primary); }
@media (hover: none) { .cal__add { opacity: .55; } }
.cal__ev--entry { background: #0d9488; }
.cal__ev--c-blue { background: #3b6fe0; } .cal__ev--c-green { background: #16a34a; } .cal__ev--c-orange { background: #ea8a0c; }
.cal__ev--c-red { background: #dc2626; } .cal__ev--c-purple { background: #9333ea; } .cal__ev--c-pink { background: #db2777; }
.cal__ev--c-teal { background: #0d9488; } .cal__ev--c-gray { background: #64748b; }
.cal__dot--entry { background: #0d9488; }
.agenda__time--blue { color: #3b6fe0; } .agenda__time--green { color: #16a34a; } .agenda__time--orange { color: #ea8a0c; }
.agenda__time--red { color: #dc2626; } .agenda__time--purple { color: #9333ea; } .agenda__time--pink { color: #db2777; }
.agenda__time--teal { color: #0d9488; } .agenda__time--gray { color: #64748b; }

/* --- status w formularzu odpowiedzi -------------------------------------------- */
.reply-state { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin: 0; display: grid; gap: 10px; min-width: 0; }
.reply-state > legend { padding: 0 6px; }
.ticket-info__status-hint { margin: 12px 0 0; }
