:root {
  /* Paleta UNSEEN (rebrand 2026-07-10): chrom panelu = fiolet marki (--brand); zieleń (--accent)
     ZOSTAJE semantyką sukcesu/statusów (umówiono, pill ok) — nie mieszamy znaczeń. */
  --bg: #0e1116; --panel: #171c26; --panel2: #202836; --line: #2c3646;
  --txt: #e8ecf3; --muted: #8b98a8; --accent: #4ade80; --accent2: #38bdf8;
  --brand: #8b7bff; --brand-deep: #6d5ae8; --brand-ink: #14101f;
  --warn: #fbbf24; --err: #f87171; --purple: #c084fc;
  /* Tokeny systemu projektowego (2026-07-02): jedna skala promieni + cieni zamiast wartości ad-hoc.
     Gęstość „operatorska": odstępy na siatce 4 px, dane liczbowe zawsze tabular-nums. */
  --r-lg: 12px;   /* karty, modale, kafle */
  --r-md: 8px;    /* przyciski, inputy, chipy prostokątne */
  --shadow-pop: 0 18px 48px rgba(0, 0, 0, .45);   /* elementy pływające (modal, toast) */
}
* { box-sizing: border-box; }
html { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #405063; }
body { margin: 0; font: 14px/1.45 system-ui, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--txt); }
h1, h2, h3, h4 { font-weight: 650; letter-spacing: -.01em; }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
button { font: inherit; font-size: 13px; cursor: pointer; border: 1px solid var(--line); background: var(--panel2);
  color: var(--txt); padding: 5px 11px; border-radius: var(--r-md); transition: border-color .12s, background .12s, filter .12s; }
button:hover { border-color: var(--accent2); }
button:active { filter: brightness(.92); }
button.primary { background: linear-gradient(135deg, var(--brand), var(--brand-deep)); color: #fff;
  border-color: var(--brand-deep); font-weight: 600; }
button.primary:hover { filter: brightness(1.1); }
button.danger { border-color: var(--err); color: var(--err); }
button.small { padding: 3px 8px; font-size: 12px; }
/* Selektor „Ile zadzwonić?" — aktywny chip podświetlony akcentem (wzór .tabs button.active). */
.ile-chip.active { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }
button:disabled { opacity: .45; cursor: default; }
button:disabled:hover { border-color: var(--line); }
input, select, textarea { font: inherit; font-size: 13px; background: var(--panel); color: var(--txt);
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 6px 9px; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent2); outline: none; box-shadow: 0 0 0 2px rgba(56,189,248,.18); }
label { display: block; margin: 6px 0; color: var(--muted); font-size: 12.5px; }
label input, label select, label textarea { display: block; width: 100%; margin-top: 4px; color: var(--txt); }
.muted { color: var(--muted); } .err { color: var(--err); min-height: 18px; }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card { background: var(--panel); padding: 28px 32px; border-radius: 14px; width: 320px; border: 1px solid var(--line); }
.login-card h1 { margin: 0; font-size: 24px; } .login-card button { width: 100%; margin-top: 12px; }

/* shell */
.app { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
aside { background: linear-gradient(180deg, #191426 0%, var(--panel) 220px); border-right: 1px solid var(--line); padding: 12px 10px; }
aside h2 { font-size: 16px; margin: 4px 8px 14px; letter-spacing: -.01em; }
/* MODUŁY sidebara (UNSEEN TalkCall / UNSEEN Social) — nagłówek zwija i rozwija własne menu.
   Zwinięta sekcja chowa <nav>, ale linki ZOSTAJĄ w DOM: dyspozytor widoków (app.js) podświetla aktywną
   zakładkę przez `aside nav a`, więc ukrywanie przez display:none nie psuje nawigacji. */
.mod + .mod { margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.mod-head { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none;
  margin: 4px 8px 8px; padding: 2px 0; border-radius: var(--r-md); }
.mod-head:hover { opacity: .85; }
.mod-head:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.mod-chev { margin-left: auto; font-size: 11px; opacity: .55; transition: transform .15s; }
.mod:not(.mod-open) .mod-chev { transform: rotate(-90deg); }
.mod:not(.mod-open) nav { display: none; }
.mod:not(.mod-open) .mod-head { margin-bottom: 4px; opacity: .72; }
/* Logotyp UNSEEN — gradientowy znak marki w nagłówku sidebara i topbarze */
.brand-mark { background: linear-gradient(92deg, var(--brand) 0%, var(--accent2) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 800; letter-spacing: .04em; }
aside nav a { display: block; padding: 7px 10px; border-left: 3px solid transparent; border-radius: 0 var(--r-md) var(--r-md) 0;
  color: var(--txt); margin-bottom: 2px; font-size: 13.5px; transition: background .12s, border-color .12s; }
aside nav a:hover { background: var(--panel2); }
/* aktywna zakładka: wcięcie marką + delikatny tint zamiast pełnej zalewki — spokojniejsza hierarchia */
aside nav a.active { background: rgba(139,123,255,.14); color: var(--brand); border-left-color: var(--brand); font-weight: 600; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.topbar .grow { flex: 1; }
@media (min-width: 761px) {
  /* desktop: pasek stanu (STOP/okno dzwonienia) zawsze w zasięgu wzroku przy długich listach */
  .topbar { position: sticky; top: 0; z-index: 30; }
}
.pill { padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pill.ok { background: rgba(74,222,128,.15); color: var(--accent); }
.pill.no { background: rgba(248,113,113,.15); color: var(--err); }
main { padding: 16px 20px 24px; }
h3 { margin: 0 0 12px; font-size: 17px; }
h4 { font-size: 13.5px; }

/* kpi — kompaktowe kafle wskaźników, etykieta w stylu data-dashboard. Gęściej (2026-07-03): węższe
   minmax → więcej kafli w rzędzie, mniejszy padding/gap → mniej pustej przestrzeni na pulpicie. */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 8px 12px; }
.kpi .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .l { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; margin-top: 1px; }

/* table — gęstość operatorska: niższe wiersze, nagłówek jak w profesjonalnych tabelach danych,
   liczby w kolumnach zawsze tabular-nums (równe cyfry = łatwe porównywanie kwot/czasów wzrokiem) */
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 10px; overflow: hidden;
  font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-weight: 600; background: var(--panel2); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
/* sticky nagłówek TYLKO we własnych kontenerach przewijania (modal, tablewrap) — na stronie
   wjeżdżałby pod sticky topbar. Page-scroll tabele zostają zwykłe. */
.modal thead th, .tablewrap thead th { position: sticky; top: 0; z-index: 1; }
tr:hover td { background: var(--panel2); }
/* pulpit: „Klienci wg statusu” — wiersze klikalne (podgląd kategorii: kto ma instalację, kto odmówił…) */
.kat-tabela tr.kat-row { cursor: pointer; }
.calls-cards { display: none; }   /* karty listy połączeń tylko na telefonie (@media ↓) */

/* Mapa (Leaflet): ZAMKNIJ wewnętrzne z-indexy Leafletu (panes 400, kontrolki 1000) we własnym
   kontekście stackingu (isolation), żeby kafle/kontrolki NIE nachodziły na szufladę nawigacji ani
   topbar na telefonie. Bez tego otwarty hamburger był przykrywany przez mapę. Nieszkodliwe na desktopie. */
#mapa-canvas { position: relative; isolation: isolate; z-index: 0; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar input, .toolbar select { padding: 5px 9px; }

/* status badges */
.badge { padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; white-space: nowrap; }
/* Chipy metryk/zużycia w szczegółach rozmowy bywają długie — w modalu wolno im zawinąć tekst,
   inaczej na wąskim ekranie wystają poza kartę (tabelowe badge'y statusów zostają nowrap). */
.modal .badge { white-space: normal; overflow-wrap: anywhere; display: inline-block; margin-bottom: 4px; }
.s-nowy { background: rgba(56,189,248,.15); color: var(--accent2); }
.s-umowiono { background: rgba(74,222,128,.18); color: var(--accent); }
.s-opt_out, .s-odmowa { background: rgba(248,113,113,.15); color: var(--err); }
.s-w_trakcie, .s-oddzwonic { background: rgba(251,191,36,.15); color: var(--warn); }
.s-nie_odebrano, .s-rozlaczono, .s-wyczerpano, .s-zrobione, .s-brak, .s-pomylka, .s-voicemail { background: var(--panel2); color: var(--muted); }
.s-aktywna, .s-zaplanowane, .s-odbyte, .s-przekazano { background: rgba(74,222,128,.18); color: var(--accent); }
.s-draft { background: rgba(56,189,248,.15); color: var(--accent2); }
.s-wstrzymana { background: rgba(251,191,36,.15); color: var(--warn); }
.s-zakonczona, .s-odwolane { background: var(--panel2); color: var(--muted); }
.s-nieodbyte { background: rgba(248,113,113,.15); color: var(--err); }
/* cykl życia POŁĄCZENIA (lista Połączeń): ongoing = na żywo (zielone), reszta = neutralne */
.s-ongoing { background: rgba(74,222,128,.20); color: var(--accent); }
.s-ended, .s-queued, .s-registered { background: var(--panel2); color: var(--muted); }
.s-error { background: rgba(248,113,113,.15); color: var(--err); }  /* status='error' jest w CHECK polaczenia.status — pełna mapa etykiet/stylów */

/* Nagłówki sekcji listy Połączeń (● Trwa teraz / 📅 Umówione / Pozostałe) — desktop (tr) i mobile (div) */
tr.sec-head td, .sec-head-card { background: var(--panel2); color: var(--muted); font-weight: 700; font-size: 11px; letter-spacing: .5px; text-transform: uppercase; }
tr.sec-head td { padding: 7px 10px; }
tr.sec-head:hover td { background: var(--panel2); }   /* nagłówek nie reaguje na hover jak wiersz danych */
.sec-head-card { padding: 7px 10px; border-radius: 8px; margin: 8px 0 2px; }
@keyframes tc-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.live-dot { color: var(--accent); animation: tc-pulse 1.4s ease-in-out infinite; }

/* Chip „termin spotkania" na liście Połączeń (rozmowy zakończone umówieniem) — data wizyty wprost przy rozmowie.
   Zielony = potwierdzony slot; niebieski = dziś; czerwony = termin minął bez statusu; bursztyn = tekstowy/do ustalenia. */
.spot-chip { display: flex; align-items: center; gap: 5px; margin-top: 5px; padding: 3px 9px; border-radius: 10px;
  background: rgba(74,222,128,.14); color: var(--accent); border: 1px solid rgba(74,222,128,.28);
  font-size: 11.5px; font-weight: 600; line-height: 1.35; white-space: nowrap; width: fit-content; max-width: 100%; }
.spot-chip.today { background: rgba(56,189,248,.18); color: var(--accent2); border-color: rgba(56,189,248,.34); }
.spot-chip.past  { background: rgba(248,113,113,.14); color: var(--err);     border-color: rgba(248,113,113,.30); }
.spot-chip.pending { background: rgba(251,191,36,.14); color: var(--warn);   border-color: rgba(251,191,36,.30); white-space: normal; }
.spot-chip-tag { margin-left: 5px; padding-left: 5px; border-left: 1px solid currentColor; font-weight: 500; font-size: 10.5px; opacity: .8; }
.ccard-spot { margin: 4px 0 2px; }   /* karta mobilna: chip na własnej linii, pod wynikiem */

/* OPS-7: pasek globalnego STOP (widoczny na każdej stronie, pod topbarem) */
.stopbar { display: flex; gap: 14px; align-items: center; justify-content: center; background: rgba(248,113,113,.18); border-bottom: 1px solid var(--err); color: var(--err); font-weight: 700; padding: 10px 20px; }
.stopbar button { border-color: var(--err); color: var(--txt); }
.btn-stop { font-size: 16px; padding: 12px 22px; font-weight: 700; }

/* zakładki (Klienci: Wszyscy / Do oddzwonienia) */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button.active { background: var(--accent); color: #06281a; border-color: var(--accent); font-weight: 600; }

/* kolejka oddzwonień: termin minął = czas dzwonić */
tr.due td { background: rgba(251,191,36,.10); }

/* karty + pasek akcji masowych */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; }
.card h4 { font-size: 13px; color: var(--muted); margin-top: 0; }
.bulkbar { display: flex; gap: 10px; align-items: center; background: var(--panel2); border: 1px solid var(--accent2); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }

/* ANA-1: lejek konwersji na Pulpicie (poziome paski, szerokość względem prób) */
.lejek { display: grid; gap: 6px; margin-bottom: 16px; }
.lejek-row { display: grid; grid-template-columns: 130px 1fr 64px; gap: 10px; align-items: center; }
.lejek-l { color: var(--muted); font-size: 12px; }
.lejek-bar { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; height: 18px; overflow: hidden; }
.lejek-fill { background: linear-gradient(90deg, var(--accent2), var(--accent)); height: 100%; border-radius: 5px; }
.lejek-v { font-weight: 700; text-align: right; }

/* ── UNSEEN Social — moduł automatyzacji Instagrama i publikacji ────────────────────────────────── */
/* Nagłówek widoku: tytuł po lewej, akcje po prawej (wzór z Klientów/Kampanii, tylko wydzielony). */
.social-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.social-head h3 { margin: 0; }
.social-head > div { display: flex; gap: 6px; }
/* Karta stanu modułu: bursztyn = czegoś brakuje, zieleń = gotowe do wysyłki. */
.card.uwaga  { border-color: rgba(224,168,73,.45); background: rgba(224,168,73,.08); }
.card.gotowe { border-color: rgba(74,193,124,.42); background: rgba(74,193,124,.08); }
/* Formularze modułu: dwie kolumny na szerokim modalu, jedna na wąskim/telefonie. */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 14px; }
.form-grid textarea { min-height: 60px; }
/* Wiersz z checkboxem — etykieta obok pola, nie nad nim (label ma display:block globalnie). */
.form-grid .chk, label.chk { display: flex; align-items: center; gap: 8px; grid-column: 1 / -1; }
label.chk input { width: auto; margin-top: 0; }

/* ANA-2: legenda wykresu 14 dni (SVG) */
.legenda { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legenda .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px;
  width: min(680px, 92vw); max-height: 88dvh; overflow: auto; box-shadow: var(--shadow-pop); }
.modal h3 { display: flex; justify-content: space-between; }
.modal h3:not(:first-child) { font-size: 14px; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.modal pre { white-space: pre-wrap; background: var(--bg); padding: 12px; border-radius: var(--r-md); max-height: 320px; overflow: auto; font-size: 12.5px; line-height: 1.5; }
audio { width: 100%; margin: 8px 0; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel2); border: 1px solid var(--accent);
  padding: 11px 16px; border-radius: 10px; z-index: 99; box-shadow: var(--shadow-pop); }
.toast.err { border-color: var(--err); }

/* ════════════════════════════════════════════════════════════════════════
   MOBILE / TOUCH — Plan-Mobile-Panel-CRM.md (2026-06).
   Wszystko za @media → desktop (pointer:fine, >760px) pozostaje bez zmian.
   Dwa konstrukty: (max-width:760px) = układ; (pointer:coarse) = cele dotykowe.
   ════════════════════════════════════════════════════════════════════════ */

/* — globalne, bezpieczne na desktopie — */
:root { color-scheme: dark; }                         /* natywne pickery/scrollbary pod ciemny motyw */
:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; } /* a11y: widoczny focus klawiatury */

/* hamburger + scrim — ukryte na desktopie, sterowane klasą body.nav-open */
#nav-toggle { display: none; background: transparent; border: 0; color: var(--txt); font-size: 22px; line-height: 1; padding: 4px 8px; cursor: pointer; }
#nav-backdrop { display: none; }
.mobonly { display: none; }   /* widoczne tylko w trybie telefonu (np. select-all Klientów) */

/* — FAZA 0/3: cele dotykowe + anti-zoom iOS (każde urządzenie dotykowe) — */
@media (pointer: coarse) {
  input, select, textarea { font-size: 16px; }       /* <16px → iOS zoom-on-focus; obejmuje też login */
  button { min-height: 44px; }
  button.small { min-height: 44px; padding: 10px 14px; font-size: 14px; }
  .toolbar input, .toolbar select, .toolbar button { min-height: 44px; }
  .card a.small, #webcall, #webhang { display: inline-flex; align-items: center; min-height: 44px; }
  input[type="checkbox"] { width: 20px; height: 20px; }
  a, button, .kal-cell { -webkit-tap-highlight-color: rgba(0,0,0,0); touch-action: manipulation; }
  button:active { border-color: var(--accent2); filter: brightness(1.12); }   /* feedback tapnięcia */
  aside nav a:active { background: var(--panel2); }
}

/* — FAZA 1/2/3/4: układ telefonu — */
@media (max-width: 760px) {
  .mobonly { display: block; }   /* select-all Klientów itp. */
  /* eksport CSV w nagłówkach h3 (Klienci/Połączenia/Spotkania): pełny cel dotykowy, bez float */
  h3 a.small { float: none !important; display: inline-flex; align-items: center; min-height: 44px; margin-top: 4px; }

  /* shell → jedna kolumna; sidebar jako szuflada off-canvas */
  .app { grid-template-columns: 1fr; }
  .app > div { min-width: 0; }                        /* pozwól treści się zwęzić (grid child default min-width:auto) */
  main { padding: 12px; overflow-x: hidden; }

  aside {
    position: fixed; inset: 0 auto 0 0; height: 100dvh; width: min(280px, 82vw);
    transform: translateX(-100%); transition: transform .22s ease;
    z-index: 2000; overflow-y: auto; overscroll-behavior: contain;   /* > Leaflet (1000) i każdej treści — szuflada zawsze na wierzchu */
  }
  body.nav-open aside { transform: translateX(0); }
  body.nav-open { overflow: hidden; }
  body.nav-open #nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1990; }
  #nav-toggle { display: inline-flex; align-items: center; }
  aside nav a { min-height: 44px; display: flex; align-items: center; }

  /* topbar KOMPAKTOWY: 2 rzędy (nie 3). Rząd 1 = ☰ · firma (rozpycha) · Wyloguj; pille (okno/dzwonienie)
     spływają na rząd 2. Kolejność przez `order` (DOM: ☰ firma okno dzwonienie grow operator logout) —
     firma flex:1 wypełnia rząd 1, pille order:3 nie mieszczą się → zawijają pod spód. Oszczędza ~44px. */
  .topbar { flex-wrap: wrap; gap: 7px 10px; padding: 8px 12px; }
  .topbar .grow { display: none; }                    /* firma rozpycha zamiast spacera-łamacza */
  #operator { display: none; }
  #nav-toggle { order: 0; }
  #firma { order: 1; flex: 1 1 auto; min-width: 0; max-width: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #logout { order: 2; }                               /* zostaje w rzędzie 1 (po prawej, wypchnięty przez firma) */
  #okno, #dzwonienie { order: 3; }                    /* pille → rząd 2 */
  #dzwonienie { cursor: pointer; }                    /* klikalny pill = STOP z telefonu (app.js, tylko dotyk) */

  /* globalny STOP zawsze widoczny przy scrollu */
  .stopbar { position: sticky; top: 0; z-index: 40; flex-wrap: wrap; }
  .stopbar #stopbar-wznow { min-height: 44px; padding: 10px 16px; font-size: 15px; }

  /* toolbary/filtry → pełnoszeroki stos */
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar input, .toolbar select, .toolbar button, .toolbar label { width: 100%; }
  .toolbar label { justify-content: flex-start; }
  .bulkbar { flex-wrap: wrap; }
  .bulkbar button { flex: 1 1 auto; }
  .tabs { flex-wrap: wrap; }

  /* inline fixed-width inputy (kalendarz config / doradcy / limit) → pełna szerokość */
  #k_godz, #k_poj, #doradcy_n, #limit { width: 100% !important; max-width: 100%; }
  /* System → Stawki kosztów + dodawanie handlowca: inline width:110px / min-width:200px nie mieściły się → pełna szerokość */
  #st_twilio, #st_sms, #st_kurs { width: 100% !important; max-width: 100%; }
  #h_nazwa { min-width: 0 !important; width: 100% !important; max-width: 100%; }
  /* Pulpit: zakładki zakresu (Dziś/7/30/Całość) — równe, kurczliwe, pełny rząd zamiast wypychania */
  #zakres-tabs button { flex: 1 1 auto; min-width: 0; }
  /* Mapa: na telefonie mapa na pełną szerokość (krótsza) + panel boczny pod spodem (inline style → !important) */
  #mapa-canvas { flex: 1 1 100% !important; min-width: 0 !important; height: 56vh !important; }
  #mapa-canvas + div { flex: 1 1 100% !important; max-width: 100%; }

  /* lejek — zwęź etykietę/wartość, żeby pasek był widoczny */
  .lejek-row { grid-template-columns: 84px 1fr 40px; }

  /* ── tabele: scroll poziomy (read-only) ── */
  .tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  /* Kalendarz (siatka 2D — NIE kartować): scroll + zamrożona kolumna „Dzień" */
  .tablewrap .kal { min-width: 560px; font-size: 12px; }
  .tablewrap .kal th, .tablewrap .kal td { padding: 4px 6px; }   /* zwężenie kolumn → mniej przewijania na telefonie */
  .tablewrap .kal th:first-child, .tablewrap .kal td:first-child { position: sticky; left: 0; background: var(--panel); z-index: 1; }
  .tablewrap .kal th:first-child { background: var(--panel2); }

  /* ── KARTY: tabele oznaczone .cardify → bloki (data-label stempluje mobile.js) ── */
  table.cardify, table.cardify tbody, table.cardify tr, table.cardify td { display: block; }
  table.cardify tr.mw-hdr { position: absolute; left: -9999px; }   /* nagłówek poza ekranem, czytelny dla SR */
  table.cardify tr {
    margin: 0 0 10px; padding: 4px 10px 8px; border: 1px solid var(--line);
    border-radius: 10px; background: var(--panel);
  }
  table.cardify tr.due { background: rgba(251,191,36,.10); }        /* zachowaj „czas dzwonić" na całej karcie */
  /* gęściej: niższe wiersze pól (min-height 26→21, padding 6→4) → karta klienta/kampanii krótsza, mniej scrolla */
  table.cardify td { border: none; padding: 4px 0 4px 42%; position: relative; min-height: 21px; word-break: break-word; }
  table.cardify td::before { content: attr(data-label); position: absolute; left: 0; top: 4px; width: 38%; color: var(--muted); font-size: 12px; font-weight: 600; }
  table.cardify td:not([data-label]) { padding-left: 0; }
  table.cardify td:not([data-label])::before { content: none; }
  table.cardify td.mw-acts { padding-left: 0; display: flex; flex-wrap: wrap; gap: 8px; padding-top: 8px; }
  table.cardify td.mw-acts::before { content: none; }
  table.cardify td.mw-acts > div { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 8px; } /* Spotkania: grupy akcji pełnoszerokie */
  table.cardify td.mw-acts .danger { flex-basis: 100%; }   /* TT-2: akcje destrukcyjne (Opt-out/Usuń) w osobnym rzędzie — anty fat-finger */
  table.cardify .badge { white-space: nowrap; }

  /* ── Lista POŁĄCZEŃ: na telefonie chowamy tabelę, pokazujemy dedykowane karty (.calls-cards z app.js).
     Flex zamiast sztywnego gridu — badge'e/meta zawijają się, nic nie ucieka poza krawędź. ── */
  table.calls-table { display: none; }
  .calls-cards { display: flex; flex-direction: column; gap: 10px; }
  .ccard { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
  .ccard-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
  .ccard-name { font-weight: 700; font-size: 15px; word-break: break-word; min-width: 0; }
  .ccard-when { color: var(--muted); font-size: 12px; white-space: nowrap; flex: none; }
  .ccard-b { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 9px 0 8px; }
  .ccard-se { color: var(--muted); font-size: 12px; }
  .ccard-m { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; color: var(--muted); font-size: 13px; }
  .ccard-m button { margin-left: auto; }

  /* ── modale → bottom sheet ── */
  .modal-bg { place-items: end center; }
  .modal {
    width: 100vw; max-width: none; max-height: 92dvh; border-radius: 16px 16px 0 0;
    padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); overscroll-behavior: contain;
  }
  .modal .primary { width: 100%; min-height: 44px; }
  .modal-close { min-height: 40px; min-width: 40px; }
  .modal td, .modal th { word-break: break-word; }
  .modal th { width: auto !important; }               /* renderDane th width:170px → auto na telefonie */

  /* toast nad klawiaturą, pełna szerokość */
  .toast { left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); }
}

/* — login: nigdy nie wychodź poza wąski ekran (style.css dzielone z login.html) — */
.login-body { min-height: 100dvh; padding: 16px; }
.login-card { width: min(320px, calc(100vw - 32px)); }

/* — Przepływ rozmowy (zakładka „Przepływ"): profesjonalny edytor grafu (inspiracja Retell) — */
.grow { flex: 1; }
.flow-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.flow-burger { display: none; }
@media (max-width: 1199px) { .flow-burger { display: inline-block; } }

/* trzy strefy: lista węzłów | płótno (pan/zoom) | wsuwany inspektor (overlay) */
.flow-shell { display: grid; grid-template-columns: 280px 1fr; height: calc(100dvh - 250px); min-height: 460px;
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; position: relative; }
.flow-outline { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; }
.flow-outline-search { display: block; width: calc(100% - 20px); margin: 10px; padding: 8px 10px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; color: var(--txt); box-sizing: border-box; }
.flow-og-head { display: flex; align-items: center; gap: 6px; padding: 9px 12px; color: var(--muted); font-size: 12px;
  font-weight: 600; cursor: pointer; user-select: none; border-top: 1px solid var(--line); }
.flow-og-head::after { content: "▼"; margin-left: auto; font-size: 9px; }
.flow-og-head.collapsed::after { content: "▶"; }
.flow-og-head.collapsed + .flow-og-body { display: none; }
.flow-orow { display: flex; gap: 7px; align-items: baseline; padding: 6px 12px 6px 18px; font-size: 12px; cursor: pointer;
  border-left: 3px solid transparent; color: var(--txt); }
.flow-orow:hover { background: var(--panel2); }
.flow-orow.active { background: rgba(56,189,248,.16); border-left-color: var(--accent2); font-weight: 600; }
.flow-orow.global { border-left-style: dashed; }
.flow-orow.dirty { border-left-color: var(--warn); }
.flow-orow .sub { color: var(--muted); font-size: 11px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flow-orow[hidden] { display: none; }

/* płótno: viewport (stały) + warstwa transformowana (pan/zoom) */
.flow-vp { position: relative; overflow: hidden; cursor: grab;
  background: var(--bg) repeating-linear-gradient(0deg, transparent, transparent 23px, rgba(255,255,255,.02) 24px),
  repeating-linear-gradient(90deg, transparent, transparent 23px, rgba(255,255,255,.02) 24px); }
.flow-vp.panning { cursor: grabbing; }
.flow-layer { position: absolute; top: 0; left: 0; transform-origin: 0 0;
  transform: translate(var(--tx,0px), var(--ty,0px)) scale(var(--z,1)); will-change: transform; }

/* karty węzłów */
.flow-node { position: absolute; width: 210px; box-sizing: border-box; background: var(--panel2); border: 1px solid var(--line);
  border-left: 4px solid var(--line); border-radius: 10px; padding: 9px 11px; z-index: 1; cursor: pointer; transition: border-color .1s, box-shadow .1s, opacity .12s; }
.flow-node:hover { border-color: var(--accent2); }
.flow-node.sel { border-color: var(--accent2); box-shadow: 0 0 0 2px rgba(56,189,248,.45); z-index: 3; }
.flow-node.near { opacity: .9; }
.flow-node.dim { opacity: .22; filter: grayscale(.4); }
.flow-node.dirty { border-left-color: var(--warn); }
.flow-node.global { border-style: dashed; background: var(--panel); }
.flow-node.is-start { box-shadow: 0 0 0 2px rgba(74,222,128,.45); }
.flow-node.t-conversation { border-left-color: var(--accent); }
.flow-node.t-function { border-left-color: var(--accent2); }
.flow-node.t-extract_dynamic_variables { border-left-color: var(--purple); }
.flow-node.t-transfer_call { border-left-color: var(--warn); }
.flow-node.t-end { border-left-color: var(--err); }
.flow-node .fn-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flow-node .fn-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.flow-node .fn-meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 11px; flex-wrap: wrap; }

/* krawędzie SVG */
.flow-edges { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 0; }
.flow-edge { pointer-events: none; }
.flow-edge-path { fill: none; stroke: #3a485a; stroke-width: 1.8; pointer-events: auto; cursor: pointer; transition: stroke .12s, stroke-width .12s; }
.flow-edge:hover .flow-edge-path, .flow-edge.hl .flow-edge-path { stroke: var(--accent2); stroke-width: 2.6; filter: drop-shadow(0 0 3px rgba(56,189,248,.35)); }
.flow-edge.g .flow-edge-path { stroke: var(--accent2); stroke-dasharray: 4 4; opacity: .55; }
.flow-edge.back .flow-edge-path { stroke-dasharray: 5 4; }
.flow-edge.dim .flow-edge-path { stroke: #1e2a38; opacity: .25; }

/* nakładki płótna (nie skalują się z grafem) */
.flow-ctrl { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 4px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 9px; padding: 4px; z-index: 5; }
.flow-ctrl button { padding: 5px 9px; }
.flow-legend { position: absolute; right: 12px; bottom: 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 10px; font-size: 11px; z-index: 5; display: flex; gap: 12px; flex-wrap: wrap; max-width: 58%; }
.flow-legend i { font-style: normal; }

/* inspektor (drawer wsuwany z prawej, nakłada się na płótno) */
.flow-inspector { position: absolute; top: 0; right: 0; width: min(370px, 100%); height: 100%; background: var(--panel);
  border-left: 1px solid var(--line); box-shadow: -4px 0 16px rgba(0,0,0,.4); transform: translateX(101%);
  transition: transform .22s cubic-bezier(.4,0,.2,1); z-index: 10; display: flex; flex-direction: column; }
.flow-inspector.open { transform: translateX(0); }
.flow-insp-head { flex: none; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--panel2); display: flex; gap: 10px; align-items: flex-start; }
.flow-insp-head h4 { margin: 0; font-size: 14px; color: var(--txt); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-insp-body { flex: 1; overflow-y: auto; padding: 14px; }
.flow-insp-body input, .flow-insp-body textarea, .flow-insp-body select { width: 100%; box-sizing: border-box; }

/* pasek zmian + wynik walidacji */
.flow-pasek { position: sticky; bottom: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 10px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
#flow-wynik { margin-top: 10px; }
#flow-wynik ul { margin: 6px 0; padding-left: 20px; } #flow-wynik li { font-size: 13px; }

@media (max-width: 1199px) {
  .flow-shell { grid-template-columns: 1fr; }
  .flow-outline { position: absolute; left: 0; top: 0; height: 100%; width: 280px; z-index: 20; transform: translateX(-101%); transition: transform .2s; }
  .flow-outline.open { transform: translateX(0); }
}
@media (max-width: 760px) {
  .flow-shell { height: calc(100dvh - 210px); }
  .flow-inspector { width: 100%; }
  .flow-legend { display: none; }
}

/* — Dziennik SMS (zakładka System): statusy wysyłki + chipy filtrów. .s-error już zdefiniowane wyżej (czerwony). — */
.s-sent { background: rgba(74,222,128,.18); color: var(--accent); }
.s-pending, .s-sending { background: rgba(251,191,36,.15); color: var(--warn); }
.s-skipped { background: var(--panel2); color: var(--muted); }
.chip { padding: 4px 10px; border-radius: 14px; font-size: 12px; border: 1px solid var(--line); background: var(--panel2); color: var(--muted); cursor: pointer; }
.chip:hover { border-color: var(--accent2); }
.chip.aktywny { border-color: var(--accent); color: var(--txt); background: rgba(74,222,128,.12); }

/* ── SEGMENTY B2B (migr. 045, rebrand UNSEEN 2026-07-10) ─────────────────────────── */
/* Chip branży na liście klientów: neutralny fioletowy tint marki; nietarget (branże '~':
   instytucje/kościoły/sieci — wykluczone z dzwonienia pulowego) wyszarzony. */
.chip-branza { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px;
  font-weight: 600; background: rgba(139,123,255,.14); color: var(--brand); white-space: nowrap; }
.chip-branza.nietarget { background: rgba(139,152,168,.14); color: var(--muted); text-decoration: line-through; }

/* Karta kreatora kampanii segmentowej — wyróżniona ramką marki (główne narzędzie tworzenia kampanii). */
.card-segment { border: 1px solid rgba(139,123,255,.35); background:
  linear-gradient(180deg, rgba(139,123,255,.06), transparent 120px), var(--panel); }
.card-segment h4 { color: var(--brand); }
.card-segment label { min-width: 130px; }
