/* ERCO Inbox — nowoczesny motyw */
:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #ff5a00;
  --accent-soft: #fff1e8;
  --sidebar: #0f172a;
  --sidebar-text: #cbd5e1;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .06);
  --new: #e11d48; --progress: #d97706; --done: #059669;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.5;
}
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 18px; }
h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin: 28px 0 12px; }
.muted { color: var(--muted); font-size: .92em; }
code { background: #eef2f7; padding: 2px 7px; border-radius: 6px; font-size: 12.5px; }

/* ── Layout ───────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }
.content { flex: 1; padding: 24px 28px; max-width: none; min-width: 0; }
.content-center { display: flex; align-items: center; justify-content: center;
  max-width: none; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────── */
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh; transition: width .15s ease, padding .15s ease;
}
.sidebar-toggle {
  position: absolute; top: 18px; right: -12px; width: 24px; height: 24px;
  border-radius: 50%; border: 1px solid rgba(255, 255, 255, .15); background: var(--sidebar);
  color: #fff; font-size: 12px; line-height: 1; cursor: pointer; display: flex;
  align-items: center; justify-content: center; z-index: 5; transition: transform .15s ease;
}
.sidebar-toggle:hover { background: rgba(255, 255, 255, .12); }
html.sidebar-collapsed .sidebar { width: 60px; padding: 20px 8px; }
html.sidebar-collapsed .sidebar-toggle { transform: rotate(180deg); }
html.sidebar-collapsed .brand { justify-content: center; padding-left: 0; padding-right: 0; }
html.sidebar-collapsed .brand span:last-child,
html.sidebar-collapsed .nav-section,
html.sidebar-collapsed .sidebar-user { display: none; }
html.sidebar-collapsed .nav-link { justify-content: center; }
html.sidebar-collapsed .nav-link span { display: none; }
html.sidebar-collapsed .sidebar-footer { justify-content: center; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none;
  font-size: 16px; padding: 4px 10px 18px; letter-spacing: -.01em; }
.brand b { font-weight: 800; }
.brand-badge { width: 30px; height: 30px; border-radius: 9px; background: var(--accent);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; box-shadow: 0 4px 12px rgba(255, 90, 0, .4); }
.sidebar nav { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 2px; }
/* dyskretny pasek przewijania na ciemnym tle */
.sidebar nav::-webkit-scrollbar { width: 6px; }
.sidebar nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 3px; }
.sidebar nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.3); }
.sidebar nav::-webkit-scrollbar-track { background: transparent; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em;
  color: #64748b; padding: 16px 12px 6px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 9px; color: var(--sidebar-text); text-decoration: none; font-size: 13.5px;
  transition: background .15s, color .15s; }
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar-footer { display: flex; align-items: center; gap: 10px; padding: 14px 10px 4px;
  border-top: 1px solid rgba(255, 255, 255, .08); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #ff5a00, #ff8c42);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.sidebar-user-name { color: #fff; font-size: 13px; font-weight: 600; }
.link-btn { background: none; border: none; color: #94a3b8; font-size: 12px; padding: 0;
  cursor: pointer; }
.link-btn:hover { color: #fff; }

/* ── Przyciski ────────────────────────────────────── */
.btn { border: 1px solid var(--border); background: var(--card); padding: 7px 15px;
  border-radius: 9px; cursor: pointer; font-size: 13.5px; font-family: inherit;
  text-decoration: none; color: var(--text); transition: all .15s; }
.btn:hover { border-color: #cbd5e1; box-shadow: var(--shadow); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff;
  font-weight: 600; box-shadow: 0 2px 8px rgba(255, 90, 0, .3); }
.btn-primary:hover { background: #e85100; border-color: #e85100; }
.btn-ghost { border: none; background: transparent; color: var(--muted); box-shadow: none; }
.btn-ghost:hover { color: var(--text); box-shadow: none; }
.btn-small { padding: 3px 10px; font-size: 12px; border-radius: 7px; }
.btn-danger { color: #b91c1c; border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; border-color: #f87171; }

/* ── Logowanie ────────────────────────────────────── */
.login-box { width: 380px; background: var(--card); padding: 40px 36px;
  border-radius: 20px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.login-box h1 { text-align: center; margin-bottom: 26px; }
.login-box label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 600;
  color: var(--muted); }
.login-box input { width: 100%; padding: 10px 12px; margin-top: 5px; font-size: 14px;
  border: 1px solid var(--border); border-radius: 10px; font-family: inherit;
  transition: border-color .15s, box-shadow .15s; }
.login-box input:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 90, 0, .12); }
.login-box button { width: 100%; margin-top: 10px; padding: 11px; font-size: 14.5px; }
.error { color: var(--new); text-align: center; font-size: 13.5px; }

/* ── Filtry (chipy) ───────────────────────────────── */
.search-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.search-bar input[type="search"] { flex: 1; max-width: 480px; padding: 9px 14px;
  border: 1px solid var(--border); border-radius: 999px; font: inherit;
  background: var(--card); }
.search-bar input[type="search"]:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 90, 0, .12); }

.filters { display: flex; gap: 7px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.filters .spacer { flex: 1; }
.chip { padding: 5px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); text-decoration: none; color: var(--muted); font-size: 12.5px;
  font-weight: 600; transition: all .15s; }
.chip:hover { color: var(--text); border-color: #cbd5e1; }
.chip.active { background: var(--text); color: #fff; border-color: var(--text); }
.chip b { margin-left: 4px; color: var(--accent); }
.chip.active b { color: #ffb380; }

/* ── Tabele / lista wątków ────────────────────────── */
.threads { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); }
.threads th { text-align: left; padding: 11px 14px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  border-bottom: 1px solid var(--border); background: #fafbfd; }
.threads td { padding: 11px 14px; border-bottom: 1px solid #eef2f7; font-size: 13.5px; }
.threads tbody tr:last-child td { border-bottom: none; }
.threads tbody tr { cursor: pointer; transition: background .1s; }
.threads tbody tr:hover { background: #f8fafc; }
.threads tr.unread td { font-weight: 650; }
.threads .subject { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Plakietki ────────────────────────────────────── */
.tag { font-size: 10.5px; padding: 3px 9px; border-radius: 6px; text-transform: uppercase;
  font-weight: 800; letter-spacing: .03em; }
.tag-allegro { background: var(--accent-soft); color: #c74600; }
.tag-email { background: #e0edff; color: #1d5fbf; }
.tag-kaufland { background: #fdeaea; color: #c8102e; }
.tag-ebay { background: #fff4e0; color: #e53238; }

.status { font-size: 11.5px; font-weight: 700; padding: 3px 11px; border-radius: 999px;
  white-space: nowrap; }
.status-nowa { background: #ffe4e6; color: var(--new); }
.status-w_toku { background: #fef3c7; color: var(--progress); }
.status-odpowiedziano { background: #d1fae5; color: var(--done); }
.status-zamknieta { background: #f1f5f9; color: var(--muted); }

.claimed { background: #fef3c7; color: #92400e; padding: 3px 11px; border-radius: 999px;
  font-size: 12px; }
.apilo-order { background: #e8f5f0; color: #0b7a55; border: 1px solid #b7e2d2;
  padding: 3px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  text-decoration: none; transition: all .15s; }
.apilo-order:hover { background: #d5efe4; }

.offer-title-banner { display: block; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 14px; margin: 14px 0 -6px; font-size: 13.5px;
  font-weight: 700; color: var(--text); text-decoration: none; transition: all .15s; }
.offer-title-banner:hover { border-color: var(--accent); background: var(--accent-soft); }

.chip-alert { border-color: #fecaca; color: #b91c1c; }
.chip-alert.active { background: #b91c1c; color: #fff; border-color: #b91c1c; }
.issue-badge { display: inline-block; font-size: 10px; font-weight: 800;
  padding: 2px 7px; border-radius: 5px; margin-right: 6px; letter-spacing: .03em; }
.issue-dispute { background: #fef3c7; color: #92400e; }
.issue-claim { background: #fee2e2; color: #b91c1c; }
.due-date { color: #b91c1c; font-weight: 700; }

.empty { text-align: center; padding: 70px 0; color: var(--muted); }
.notice { background: #fffbeb; border: 1px solid #fde68a; padding: 12px 16px;
  border-radius: 12px; margin-bottom: 16px; font-size: 13.5px; }
.notice code { background: #fff; }

/* ── Widok wątku ──────────────────────────────────── */
.thread-head h1 { margin: 10px 0 8px; font-size: 20px; }
.thread-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13px; }

/* Układ dwukolumnowy wątku (wzorowany na eDesk/Responso) — rozmowa + stały
   panel kontekstu zamówienia obok, zamiast plakietek rozproszonych nad
   wiadomościami. Poniżej 1000px panel spada pod rozmowę (mobile/wąski split). */
.thread-layout { display: flex; gap: 20px; align-items: flex-start; }
.thread-main { flex: 1; min-width: 0; }
.thread-sidebar { width: 260px; flex-shrink: 0; display: flex; flex-direction: column;
  gap: 12px; position: sticky; top: 16px; }
@media (max-width: 1000px) {
  .thread-layout { flex-direction: column; }
  .thread-sidebar { width: 100%; position: static; }
}
.sidebar-card { background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.sidebar-card h3 { margin: 0 0 6px; font-size: 11px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; }
.sidebar-card p { margin: 0 0 4px; font-size: 13.5px; }
.sidebar-card form { margin-top: 4px; }
.country-badge { display: inline-block; background: #eff6ff; color: #1d4ed8;
  border: 1px solid #bfdbfe; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.sidebar-card.sla-warn { background: #fff7ed; border-color: #fed7aa; }
.sidebar-card.sla-over { background: #fef2f2; border-color: #fecaca; }

/* Status doręczenia przesyłki (Allegro) — kolor niesie informację od razu:
   zielony = dotarła, czerwony = problem/zwrot, żółty = czeka na odbiór. */
.ship-status { display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 800; background: #f1f5f9; color: #475569; }
.ship-delivered { background: #d1fae5; color: #065f46; }
.ship-in_transit, .ship-released_for_delivery { background: #dbeafe; color: #1d4ed8; }
.ship-available_for_pickup, .ship-notice_left { background: #fef9c3; color: #854d0e; }
.ship-issue, .ship-returned { background: #fee2e2; color: #b91c1c; }
.messages { margin: 22px 0; display: flex; flex-direction: column; gap: 12px; }
.msg { background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 12px 16px; max-width: 72%; box-shadow: var(--shadow); }
.msg-in { align-self: flex-start; border-bottom-left-radius: 4px; }
.msg-out { align-self: flex-end; background: linear-gradient(180deg, #fff7f2, #fff1e8);
  border-color: #ffd9c2; border-bottom-right-radius: 4px; }
.msg-head { display: flex; gap: 10px; font-size: 12.5px; margin-bottom: 5px; align-items: baseline; }
.msg-body { white-space: pre-wrap; font-size: 14px; }
.msg-html { width: 100%; border: none; background: #fff; border-radius: 8px;
  min-height: 40px; resize: vertical; overflow: auto; }
/* Maile HTML (Amazon/eBay/inne) dostawały max-width:100% — spłaszczało to
   dymek w pełnoszerokościowy blok, znikał efekt "rozmowy". Ograniczona
   szerokość (nadal szersza niż zwykła wiadomość tekstowa, bo maile bywają
   zrzeszotowane tabelami/obrazkami) zachowuje wygląd dymka; treść szersza
   niż to i tak przewija się w poziomie wewnątrz ramki (.msg-html overflow:auto). */
.msg:has(.msg-html) { max-width: min(720px, 92%); width: 100%; }
.att-link { display: inline-block; margin: 6px 8px 0 0; padding: 4px 12px;
  background: #f1f5f9; border: 1px solid var(--border); border-radius: 999px;
  font-size: 12.5px; text-decoration: none; color: var(--text); transition: all .15s; }
.att-link:hover { border-color: var(--accent); background: var(--accent-soft); }
/* Załącznik, którego nie udało się pobrać z platformy — widoczne ostrzeżenie
   zamiast niemej ikony zepsutego obrazka (patrz onerror w _thread_messages). */
.att-failed { background: #fef2f2; border-color: #fca5a5; color: #7f1d1d; }

.ai-sug { border: 1px solid var(--border); border-left: 3px solid #7c5cff;
  border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; background: #fbfaff; }
.ai-sug-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px;
  font-size: 12.5px; flex-wrap: wrap; }
.ai-score { background: #efeaff; color: #5b3df5; font-weight: 700; padding: 2px 10px;
  border-radius: 999px; font-size: 11.5px; }
.ai-sug-body { font-size: 13.5px; white-space: pre-wrap; max-height: 150px; overflow-y: auto; }

/* Oryginał obcojęzycznej wiadomości — domyślnie zwinięty (wzorzec Responso/
   Zendesk: pokazuj tylko tłumaczenie, oryginał na żądanie), żeby nie dublować
   wysokości dymka dla każdej wiadomości niepolskiej. */
.msg-original { margin-top: 6px; }
.msg-original summary { cursor: pointer; font-size: 11.5px; font-weight: 700;
  color: #4338ca; list-style: none; }
.msg-original summary::-webkit-details-marker { display: none; }
.msg-original summary::before { content: "▸ "; }
.msg-original[open] summary::before { content: "▾ "; }
.msg-original[open] summary { margin-bottom: 6px; }
.msg-original-body { background: #eef2ff; border: 1px solid #c7d2fe;
  border-radius: 10px; padding: 8px 12px; }
.msg-original-body .msg-body { font-size: 13.5px; }

/* Karta pól Produkt/Zamówienie/Żądanie zwrotu — wzorowana na czytelnym
   układzie wiadomości w Amazon Seller Central (etykieta: wartość w osobnych
   wierszach) zamiast tej samej treści sklejonej w jeden akapit. */
.msg-meta { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; margin-top: 8px; font-size: 13px; }
.msg-meta-row { display: flex; gap: 8px; padding: 2px 0; }
.msg-meta-row:not(:last-child) { border-bottom: 1px dashed #e2e8f0; }
.msg-meta-label { font-weight: 700; color: #475569; min-width: 130px; flex-shrink: 0; }
.msg-meta-relayed { display: inline-block; margin-top: 6px; font-size: 11.5px;
  color: #64748b; }

.apilo-panel { background: #e8f5f0; border: 1px solid #b7e2d2; border-radius: var(--radius);
  padding: 10px 16px; margin: 14px 0; }
.apilo-panel-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  font-size: 13.5px; }
.apilo-panel select { padding: 5px 8px; border: 1px solid #b7e2d2; border-radius: 7px;
  font: inherit; max-width: 220px; }

.combo-wrap { position: relative; display: inline-block; }
.combo-dropdown { position: absolute; top: 100%; left: 0; margin-top: 4px; z-index: 30;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); width: 220px; max-height: 260px; overflow-y: auto; }
.combo-option { padding: 7px 12px; font-size: 13px; cursor: pointer; }
.combo-option:hover { background: var(--accent-soft); }
.combo-empty { padding: 7px 12px; font-size: 13px; color: var(--muted); }

.notes-box { background: #fefce8; border: 1px solid #fde68a; border-radius: var(--radius);
  padding: 10px 16px; margin: 14px 0; }
.notes-title { font-size: 11.5px; font-weight: 700; color: #92400e;
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.note-item { font-size: 13.5px; padding: 3px 0; border-bottom: 1px dashed #fde68a; }
.note-item:last-child { border-bottom: none; }

.auto-badge { display: inline-block; font-size: 10.5px; font-weight: 800;
  padding: 2px 7px; border-radius: 5px; background: #ede9fe; color: #5b21b6; }
.sla-badge { display: inline-block; font-size: 10.5px; font-weight: 800;
  padding: 2px 7px; border-radius: 5px; }
.sla-ok { background: #f1f5f9; color: #475569; }
.sla-warn { background: #ffedd5; color: #c2410c; }
.sla-over { background: #fee2e2; color: #b91c1c; }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px;
  padding: 10px 0; font-size: 13px; }
.send-pending { font-size: 11.5px; color: #b45309; font-weight: 700; }
.send-failed { font-size: 11.5px; color: #b91c1c; font-weight: 700; }
.send-error-box { background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px;
  padding: 6px 10px; margin-bottom: 6px; font-size: 12.5px; color: #7f1d1d;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.urgent-banner { display: flex; justify-content: space-between; align-items: center;
  gap: 14px; background: #fef2f2; border: 2px solid #fca5a5; border-radius: 12px;
  padding: 12px 16px; margin-bottom: 14px; color: #7f1d1d; }
.urgent-banner b { font-size: 14.5px; }
.chip-urgent { border-color: #fca5a5; background: #fef2f2; color: #b91c1c; font-weight: 700; }
.chip-urgent.active { background: #b91c1c; color: #fff; border-color: #b91c1c; }
.deescalation-box { background: #fdf4ff; border: 1px solid #e9d5ff; border-radius: 10px;
  padding: 12px 14px; margin-bottom: 14px; font-size: 13.5px; white-space: pre-wrap; }

/* ── Widok dzielony (lista + podgląd) ─────────────── */
.split { display: flex; gap: 16px; align-items: flex-start; }
.split-list { width: 480px; flex-shrink: 0; max-height: calc(100vh - 118px);
  overflow-y: auto; border-radius: var(--radius); }
.split-list .threads td { padding: 9px 10px; }
.split-pane { flex: 1; min-width: 0; position: sticky; top: 20px;
  height: calc(100vh - 118px); }
#pane { width: 100%; height: 100%; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.split-pane .empty { background: var(--card); border: 1px dashed var(--border);
  border-radius: var(--radius); height: 100%; display: flex; flex-direction: column;
  justify-content: center; }
.check-cell { width: 30px; text-align: center; }
.check-cell input { cursor: pointer; }

.bulk-bar { display: flex; align-items: center; gap: 12px; background: var(--text);
  color: #fff; padding: 10px 16px; border-radius: 12px; margin-bottom: 12px;
  font-size: 13.5px; }
.bulk-bar select { padding: 6px 10px; border-radius: 7px; border: none; font: inherit; }
.bulk-bar .btn-primary { box-shadow: none; }
.bulk-bar .btn { border-color: transparent; }

.split-list tr.sel td { background: var(--accent-soft); }
.split-list tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.dot-cell { width: 18px; color: var(--accent); }
.who { font-weight: 650; font-size: 13px; }
.who-sub { display: flex; gap: 8px; align-items: center; margin-top: 3px; font-size: 11.5px; }
.who-cell { width: 150px; }
/* Wiersz listy jako siatka, nie kolumny tabeli — temat dostaje CAŁĄ szerokość
   panelu w drugim rzędzie, zamiast dzielić ~200px z nazwą klienta (zgłoszone:
   "nie widać tytułów wiadomości"). Nazwa, platforma i data lądują w jednym
   rzędzie nad tematem. _thread_list.html jest używany wyłącznie tutaj. */
.split-list .threads,
.split-list .threads thead,
.split-list .threads tbody { display: block; }
.split-list .threads thead tr { display: flex; align-items: center;
  justify-content: space-between; }
.split-list .threads tbody tr {
  display: grid;
  grid-template-columns: 26px 14px 1fr auto;
  grid-template-areas: "check dot who     actions"
                       "check dot subject subject";
  align-items: start;
  row-gap: 1px;
  padding: 7px 10px;
  border-bottom: 1px solid #eef2f7;
}
.split-list .threads tbody tr:last-child { border-bottom: none; }
.split-list .threads tbody td { padding: 0; border-bottom: none; }
.split-list .check-cell { grid-area: check; }
.split-list .dot-cell { grid-area: dot; }
.split-list .who-cell { grid-area: who; width: auto; display: flex;
  align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.split-list .who-cell .who-sub { margin-top: 0; }
.split-list .who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 190px; }
.split-list .main-cell { grid-area: subject; min-width: 0; }
.split-list .main-cell .who-sub { margin-top: 2px; }
.split-list .row-actions { grid-area: actions; }
.split-list tr.sel td:first-child { box-shadow: none; }
.split-list tr.sel { box-shadow: inset 3px 0 0 var(--accent); }
.split-list .subject { max-width: none; white-space: normal; font-size: 13px;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* Osadzenie w ramce podglądu — bez sidebara i przycisku powrotu */
.embedded .sidebar { display: none; }
.embedded .content { padding: 18px 22px; max-width: none; }
.embedded .back-link { display: none; }

@media (max-width: 900px) {
  .split-pane { display: none; }
  .split-list { width: 100%; max-height: none; }
}
/* ── Samouczek ─────────────────────────────────────── */
.onboarding-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .55);
  z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.onboarding-box { background: var(--card); border-radius: 18px; box-shadow: var(--shadow);
  width: 100%; max-width: 520px; max-height: 85vh; overflow-y: auto;
  padding: 32px 32px 20px; position: relative; }
.onboarding-close { position: absolute; top: 14px; right: 14px; border: none;
  background: none; font-size: 18px; color: var(--muted); cursor: pointer;
  width: 32px; height: 32px; border-radius: 8px; }
.onboarding-close:hover { background: var(--bg); color: var(--text); }
.onboarding-step h2 { margin: 0 0 14px; font-size: 19px; }
.onboarding-step p { margin: 0 0 12px; font-size: 14px; line-height: 1.55; }
.onboarding-step ul { margin: 0 0 12px; padding-left: 20px; font-size: 14px; line-height: 1.6; }
.onboarding-nav { display: flex; align-items: center; justify-content: space-between;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.onboarding-dots { display: flex; gap: 6px; }
.onboarding-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--border); }
.onboarding-dot.active { background: var(--accent); width: 18px; transition: width .15s; }
.onboarding-buttons { display: flex; gap: 8px; }

.msg-attachments { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 8px; }
.att-img-preview { max-width: 220px; max-height: 220px; border-radius: 8px;
  border: 1px solid var(--border); display: block; cursor: zoom-in; object-fit: cover; }
.att-img-preview:hover { border-color: var(--accent); }

.reply-box { background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.reply-box textarea { width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font: inherit; resize: vertical; transition: border-color .15s, box-shadow .15s; }
.reply-box textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 90, 0, .12); }
.reply-actions { margin-top: 10px; display: flex; gap: 10px; }
.status-form { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border);
  display: flex; gap: 8px; align-items: center; }
.status-form select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 9px;
  font-family: inherit; }

/* ── Formularze (pracownicy / skrzynki / szablony) ─── */
.add-user-form { background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; display: flex; gap: 14px;
  align-items: flex-end; flex-wrap: wrap; box-shadow: var(--shadow); }
.add-user-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px;
  font-weight: 600; color: var(--muted); }
.add-user-form label.inline { flex-direction: row; align-items: center; }
.add-user-form input { padding: 8px 11px; border: 1px solid var(--border); border-radius: 9px;
  font-family: inherit; }
.add-user-form input:focus { outline: none; border-color: var(--accent); }

.tpl { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 10px; box-shadow: var(--shadow); }
.tpl summary { cursor: pointer; font-size: 14px; }
.tpl-edit { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.tpl-edit input, .tpl-edit textarea { padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 9px; font: inherit; }
.tpl-edit input:focus, .tpl-edit textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 90, 0, .12); }
.tpl-picker { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.tpl-picker select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 9px;
  max-width: 340px; font-family: inherit; }

/* ── Reguły ───────────────────────────────────────── */
.rule-form { display: flex; gap: 24px; flex-wrap: wrap; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); }
.rule-col { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 9px; }
.rule-col h3 { margin: 0 0 4px; font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); }
.rule-col label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px;
  font-weight: 600; color: var(--muted); }
.rule-col label.inline { flex-direction: row; align-items: center; gap: 7px; }
.rule-col input, .rule-col select { padding: 8px 11px; border: 1px solid var(--border);
  border-radius: 9px; font: inherit; color: var(--text); }
.rule-col input:focus, .rule-col select:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 90, 0, .12); }

/* ── Statystyki ───────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px; margin-bottom: 20px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.kpi-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-in { background: #1d5fbf; }
.dot-out { background: var(--accent); }

.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: #eef2f7; stroke-width: 1; }
.chart .axis-line { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .bar-in { fill: #1d5fbf; }
.chart .bar-out { fill: var(--accent); }
.chart .bar { transition: opacity .1s; }
.chart .bar:hover { opacity: .75; }

/* ── Responsywność ────────────────────────────────── */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row;
    align-items: center; padding: 10px 14px; gap: 6px; overflow-x: auto; }
  .sidebar nav { flex-direction: row; align-items: center; }
  .nav-link span { display: none; }
  .nav-section { display: none; }
  .brand span:last-child { display: none; }
  .sidebar-footer { border: none; padding: 0; margin-left: auto; }
  .sidebar-user { display: none; }
  .content { padding: 16px; }
  .msg { max-width: 92%; }
}

/* ── Uprawnienia do sekcji (/admin/users) ─────────── */
/* Selektory celowo zawężone do .sections-form — reguła z gwiazdką potrafiła
   już w tym projekcie rozjechać cudze panele. */
.sections-form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.sections-presets { display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  font-size: 12.5px; font-weight: 600; color: var(--muted); }
.sections-grid { display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.sections-form .section-item { display: flex; gap: 9px; align-items: flex-start;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; font-size: 13px; }
.sections-form .section-item:hover { border-color: #cbd5e1; }
.sections-form .section-item input { margin-top: 2px; }
.sections-form .section-item em { display: block; margin-top: 2px; font-style: normal;
  font-size: 11.5px; color: var(--muted); }
