/* platform/public/assets/css/app.css — wspólne style platformy
   Redesign wg handoffu "MultiInbox Redesign" v2 (Claude Design):
   Hanken Grotesk (UI) + Bricolage Grotesque (display) + JetBrains Mono (dane),
   ciepła paleta, ikony SVG zamiast emoji. */

:root {
  --primary: #1F4B99;       /* per-tenant nadpisywane inline w inbox.php */
  --primary-soft: #EAF0FB;
  --bg: #FAF9F6;
  --surface: #FFFFFF;
  --border: #E6E0D1;
  --border-soft: #F3EFE4;
  --text: #14171C;
  --muted: #4B5563;
  --muted-2: #8B8F98;
  --white: #fff;

  --success: #1F7A4D;
  --success-soft: #E4F5EA;
  --warn: #9A6300;
  --warn-soft: #FBF0D9;
  --danger: #B3261E;
  --danger-soft: #FBE8E6;

  /* pary tło/tekst awatarów (nadpisywane przez motyw ciemny) */
  --av1-bg: #EAF0FB; --av1-fg: #1F4B99;  /* niebieski */
  --av2-bg: #E4F5EA; --av2-fg: #1F7A4D;  /* zielony */
  --av3-bg: #FBF0D9; --av3-fg: #9A6300;  /* bursztyn */
  --av4-bg: #FBE8E6; --av4-fg: #B3261E;  /* czerwony */
  --av5-bg: #F0E9FB; --av5-fg: #6B3FA0;  /* fioletowy */
  --av6-bg: #E2F3F5; --av6-fg: #0F6674;  /* morski */
  --av7-bg: #FBE9F2; --av7-fg: #A62667;  /* różowy */
  --av8-bg: #EDF3E2; --av8-fg: #4F6F1F;  /* oliwkowy */
  --av-al-bg: #FDEBD7; --av-al-fg: #B45A00; /* awatar systemowy Allegro */

  --font-ui: 'Hanken Grotesk', system-ui, -apple-system, sans-serif;
  --font-display: 'Bricolage Grotesque', 'Hanken Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

/* ---------- Paski przewijania — smukłe, w kolorach motywu ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb, #D5D0C4) transparent; } /* Firefox */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb, #D5D0C4);
  border-radius: 8px;
  border: 2px solid transparent; /* "odchudza" uchwyt do ~5px */
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover, #B9B3A4); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-corner { background: transparent; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-weight: 700; }
code { background: var(--border-soft); padding: 1px 5px; border-radius: 4px; font-size: 12px; font-family: var(--font-mono); }
pre { background: var(--border-soft); padding: 10px; border-radius: 10px; overflow-x: auto; font-family: var(--font-mono); }
svg { vertical-align: -2px; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }

/* ---------- Przyciski / formularze ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-ui);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { filter: brightness(0.95); text-decoration: none; }
.btn-outline { background: var(--surface); color: var(--primary); border-color: var(--border); }
.btn-sm { padding: 4px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { padding: 13px 28px; font-size: 15.5px; }
/* wyjątek z handoffu: małe pigułki tylko w pasku trybu odpowiedzi */
.reply-mode .btn-sm { border-radius: 16px; padding: 5px 14px; }

/* przyciski-ikony (pasek akcji nad listą) */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 7px;
  border: 1px solid transparent; background: none; color: var(--muted);
  cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--border-soft); color: var(--text); }

label { display: block; margin: 10px 0; font-weight: 600; }
label small { font-weight: 400; color: var(--muted-2); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], input[type="color"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  margin-top: 5px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
label.checkbox { font-weight: 400; }
label.checkbox input { width: auto; margin-right: 6px; }
textarea { resize: vertical; }
.form { max-width: 860px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 20px; }
.form-inline { display: flex; gap: 10px; align-items: center; max-width: 500px; }

.flash { padding: 10px 16px; border-radius: 10px; margin: 10px 16px; }
.flash-success { background: var(--success-soft); color: var(--success); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-info { background: var(--primary-soft); color: var(--primary); }
.text-error { color: var(--danger); }
.nowrap { white-space: nowrap; }
.hint { color: var(--muted); }

.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.table th, .table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border-soft); }
.table th { background: var(--border-soft); font-weight: 600; font-size: 12.5px; }
.table td small { color: var(--muted-2); }

/* ---------- Górny pasek ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--topbar-bg, var(--surface));
  border-bottom: 1px solid var(--border);
  padding: 9px 18px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 800; color: var(--text); font-family: var(--font-display); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand svg { color: var(--primary); }
.brand-logo { height: 30px; }
.topbar-search { flex: 1; max-width: 640px; position: relative; }
.topbar-search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted-2); }
.topbar-search input { border-radius: 24px; background: var(--bg); border: 1px solid transparent; padding: 10px 18px 10px 38px; margin-top: 0; }
.topbar-search input:focus { background: var(--surface); border-color: var(--border); }
.topbar-nav { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.topbar-nav a { color: var(--muted); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.topbar-nav a:hover { color: var(--text); text-decoration: none; }
.topbar-nav a.active { font-weight: 700; color: var(--text); }
.topbar-user { color: var(--muted-2); }

.footer { text-align: center; color: var(--muted-2); padding: 22px; font-size: 13px; }

/* ---------- Logowanie / rejestracja (split-screen) + instalator ---------- */

.auth-box {
  max-width: 420px;
  margin: 60px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 30px 34px;
}
.auth-box h1 { margin-top: 0; }
.auth-box .flash { margin: 10px 0; }

.auth-split { display: flex; min-height: 100vh; }
.auth-left {
  flex: 0 0 55%;
  background: var(--text);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px 56px;
}
.auth-left .brand { color: #fff; font-size: 19px; }
.auth-left .brand svg { color: #fff; }
.auth-quote { font-size: 27px; font-weight: 700; line-height: 1.35; max-width: 480px; }
.auth-quote small { display: block; margin-top: 16px; font-size: 14px; font-weight: 400; color: rgba(255,255,255,.65); }
.auth-copy { color: rgba(255,255,255,.5); font-size: 13px; }
.auth-right {
  flex: 1;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
}
.auth-card {
  width: 400px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 24px; }
.auth-card .auth-sub { color: var(--muted-2); margin: 0 0 14px; }
.auth-card .btn { width: 100%; justify-content: center; }
.auth-card .auth-alt { text-align: center; margin-top: 14px; color: var(--muted); }
.auth-card .flash { margin: 10px 0; }

/* ---------- Landing ---------- */

.landing { background: var(--surface); }
.landing-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 34px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 10;
}
.landing-brand { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 800; color: var(--text); font-family: var(--font-display); letter-spacing: -.01em; }
.landing-brand svg { color: var(--primary); }
.landing-header nav { display: flex; gap: 22px; align-items: center; }
.landing-header nav a { color: var(--muted); font-weight: 500; }
.landing-header nav a:hover { color: var(--text); text-decoration: none; }
.landing-header nav a.btn { color: #fff; }

.hero { text-align: center; padding: 76px 20px 60px; background: var(--bg); }
.hero-eyebrow {
  display: inline-block;
  font-family: var(--font-mono); font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--primary); background: var(--primary-soft);
  padding: 6px 16px; border-radius: 20px; margin-bottom: 22px;
}
.hero h1 { font-size: 48px; font-weight: 800; margin: 0 0 16px; line-height: 1.12; font-family: var(--font-display); letter-spacing: -.01em; }
.hero p { font-size: 17px; color: var(--muted); max-width: 600px; margin: 0 auto 30px; }
.hero-ctas { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
  max-width: 1100px;
  margin: 48px auto;
  padding: 0 20px;
}
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.feature-icon {
  width: 38px; height: 38px; border-radius: 9px; background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.feature h3 { margin: 0 0 6px; font-size: 16.5px; font-weight: 600; }
.feature p { color: var(--muted); font-size: 14px; margin: 0; }

.pricing { text-align: center; padding: 44px 20px 64px; background: var(--bg); border-top: 1px solid var(--border); }
.pricing h2 { font-size: 28px; font-family: var(--font-display); letter-spacing: -.01em; }
.pricing-grid { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }
.price-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 26px; width: 264px; }
.price-card.featured { border-color: var(--primary); }
.price-tag {
  position: absolute; top: -11px; left: 18px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em;
  background: var(--primary); color: #fff; border-radius: 12px; padding: 3px 12px;
}
.price-card .price { font-size: 32px; font-weight: 800; margin: 10px 0; }
.price-card .price span { font-size: 14px; color: var(--muted-2); font-weight: 400; }
.price-card ul { text-align: left; padding-left: 20px; color: var(--muted); }
.pricing-note { color: var(--muted-2); max-width: 700px; margin: 26px auto 0; }

/* ---------- Panel ustawień ---------- */

.settings-wrap { display: flex; min-height: calc(100vh - 100px); background: var(--surface); }
.settings-nav { width: 230px; padding: 18px 0; background: var(--surface); border-right: 1px solid var(--border); }
.settings-nav ul { list-style: none; margin: 0; padding: 0; }
.settings-nav li a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; color: var(--muted);
  border-radius: 0 20px 20px 0; font-weight: 500;
}
.settings-nav li a svg { flex-shrink: 0; }
.settings-nav li a:hover { background: var(--border-soft); color: var(--text); text-decoration: none; }
.settings-nav li.active a { background: var(--primary-soft); font-weight: 700; color: var(--primary); }
.settings-main { flex: 1; background: var(--surface); padding: 28px 34px; }
.settings-main h1 { display: flex; align-items: center; gap: 16px; font-size: 22px; margin-top: 0; }
.cards { display: flex; gap: 16px; flex-wrap: wrap; }
.card { border: 1px solid var(--border); border-radius: 12px; padding: 18px 26px; min-width: 150px; text-align: center; background: var(--surface); }
.card-num { font-size: 28px; font-weight: 800; color: var(--primary); }
.steps li { margin: 6px 0; color: var(--muted); line-height: 1.9; }

/* ---------- Skrzynka (styl Gmail) ---------- */

.inbox-page { overflow: hidden; }
.inbox-layout { display: flex; height: calc(100vh - 53px); }

.inbox-sidebar {
  width: 230px;
  padding: 14px 8px 14px 0;
  overflow-y: auto;
  flex-shrink: 0;
  background: var(--sidebar-bg, var(--surface));
  border-right: 1px solid var(--border);
}
.btn-compose {
  display: flex; justify-content: center;
  width: calc(100% - 32px); margin: 4px 16px 6px;
  padding: 12px; border-radius: 10px; font-size: 14.5px;
  box-shadow: 0 1px 3px rgba(20,23,28,.14);
}
.sidebar-section {
  font-family: var(--font-mono); font-size: 11px; text-transform: uppercase;
  color: var(--muted-2); padding: 12px 16px 5px; letter-spacing: .06em;
}
/* pierwszy nagłówek (SKRZYNKI) bliżej przycisku Napisz */
.btn-compose + .sidebar-section { padding-top: 2px; }
.sidebar-empty { padding: 4px 16px; color: var(--muted-2); }
.channel-list, .folder-list { list-style: none; margin: 0; padding: 0; }
.channel-list li, .folder-list li {
  padding: 7px 16px;
  border-radius: 0 20px 20px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
  overflow: hidden;
  color: var(--text);
}
#channel-list li { align-items: center; padding: 7px 16px; }
/* kafelek skrzynki: kolor + ikona zamiast kropki */
.ch-ico {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.ch-ico svg { vertical-align: 0; }
/* własna wgrana ikona kafelka */
.ch-ico-img { padding: 0; overflow: hidden; background: var(--border-soft); }
.ch-ico-img img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
/* litera jako ikona kafelka (kolory z wybranej palety) */
.ch-ico-letter { font-weight: 700; font-size: 14px; font-family: var(--font-ui); line-height: 1; }
/* oficjalny znak Allegro (pomarańczowy kafelek z białym "a") */
.ch-ico-allegro {
  background: #FF5A00; color: #fff; font-weight: 800; font-size: 19px;
  font-family: var(--font-display); line-height: 1; padding-bottom: 4px;
}

/* wybór koloru/ikony kafelka skrzynki (Ustawienia → Skrzynki → Wygląd) */
.tile-preview-row { display: flex; align-items: center; gap: 10px; margin: 10px 0 16px; }
.pick-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }
.pick-swatch { cursor: pointer; }
.pick-swatch input { display: none; }
.pick-swatch .ch-ico { width: 34px; height: 34px; border: 2px solid transparent; }
.pick-swatch input:checked + .ch-ico { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.pick-swatch:hover .ch-ico { border-color: var(--border); }
.pick-dot { width: 12px; height: 12px; border-radius: 50%; }
.pick-auto { background: var(--border-soft); color: var(--muted); font-weight: 700; font-size: 13px; }
.pick-neutral { background: var(--border-soft); color: var(--muted); }
.ch-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.ch-info small { overflow: hidden; text-overflow: ellipsis; }
.channel-list li small, .folder-list li small { color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.channel-list li:hover, .folder-list li:hover { background: var(--border-soft); }
/* podpunkty folderów (Dyskusje/Reklamacje → Otwarte/Zamknięte/…) */
.folder-list li.sub { padding: 5px 16px 5px 28px; font-size: 13.5px; color: var(--text); }
.folder-list li.sub .folder-ico { opacity: 1; color: var(--primary); width: 13px; height: 13px; }
/* drugi wskaźnik przy "Otwarte": liczba wszystkich otwartych spraw —
   zaraz za etykietą; licznik nieprzeczytanych zostaje przy prawej krawędzi */
.folder-total {
  flex-shrink: 0;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  color: var(--badge-total-fg, var(--primary)); background: var(--badge-total-bg, var(--primary-soft)); border: none;
  border-radius: 10px; padding: 0 7px; line-height: 17px;
}
.channel-list li.active, .folder-list li.active { background: var(--primary-soft); font-weight: 700; }
.channel-list li.disabled { color: var(--muted-2); cursor: default; opacity: .7; }
.channel-list li.disabled:hover { background: none; }
.ch-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); flex-shrink: 0; }

/* nagłówek grupy skrzynek — zwijany */
.channel-list li.ch-group {
  padding: 8px 16px 3px; cursor: pointer; border-radius: 0;
  font-family: var(--font-mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted-2); gap: 6px;
}
.channel-list li.ch-group:hover { background: none; color: var(--muted); }
.channel-list li.ch-group .grp-chev { transition: transform .15s; flex-shrink: 0; }
.channel-list li.ch-group.collapsed .grp-chev { transform: rotate(-90deg); }
/* suma nieprzeczytanych w grupie — delikatna chmurka */
.channel-list li.ch-group .grp-unread {
  margin-left: auto; flex-shrink: 0;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
  letter-spacing: 0; text-transform: none;
  color: var(--badge-chan-fg, var(--primary)); background: var(--badge-chan-bg, var(--primary-soft));
  border-radius: 10px; padding: 1px 7px;
}

/* licznik nieprzeczytanych przy skrzynce — stonowany (piaskowy, nie niebieski) */
.ch-unread {
  margin-left: auto;
  flex-shrink: 0;
  align-self: center;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--badge-chan-fg, var(--primary));
  background: var(--badge-chan-bg, var(--primary-soft));
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 1px 7px;
}
.ch-unread:empty { display: none; }

/* statusy zbiorcze (nad skrzynkami) */
.sidebar-section .status-help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; margin-left: 6px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  font-size: 10.5px; font-weight: 700; letter-spacing: 0; text-transform: none;
  cursor: pointer; vertical-align: -3px;
}
.sidebar-section .status-help:hover { background: var(--primary); color: #fff; text-decoration: none; }
#status-list { margin-bottom: 4px; }
#status-list .folder-unread { margin-left: auto; }
/* ikona skrzynki zamiast inicjałów na liście statusu — rozmiar jak awatar */
.ti-side .ch-ico { width: 27px; height: 27px; border-radius: 8px; }
.ti-side .ch-ico svg { width: 14px; height: 14px; }
/* etykieta skrzynki źródłowej w wierszu listy (widok statusu zbiorczego) */
.ti-chan {
  flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--muted-2); font-size: 11px; margin: 2px 6px 0 auto; max-width: 40%;
}

/* ikony folderów w lewym menu */
.folder-ico { flex-shrink: 0; color: var(--muted-2); }
.folder-list li.active .folder-ico { color: var(--primary); }
.folder-label { overflow: hidden; text-overflow: ellipsis; }

/* mini edytor HTML stopki */
.html-editor { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); margin: 6px 0 14px; }
.he-toolbar { display: flex; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--border-soft); flex-wrap: wrap; }
.he-toolbar button {
  border: 1px solid transparent; background: none; border-radius: 6px;
  padding: 3px 9px; cursor: pointer; font-size: 13px; color: var(--muted);
}
.he-toolbar button:hover { background: var(--bg); border-color: var(--border); color: var(--text); }
.he-area { min-height: 96px; padding: 10px 12px; outline: none; font-size: 14px; line-height: 1.5; }
.he-area:focus { background: var(--surface); }
.he-area a { color: var(--primary); }
.he-area:empty::before { content: attr(data-placeholder); color: var(--muted-2); pointer-events: none; }
.rich-editor { margin: 6px 0 8px; }
.rich-editor .he-area { max-height: 320px; overflow-y: auto; }

/* autouzupełnianie adresów (jak w Gmailu) */
.ac-box {
  position: fixed; z-index: 400; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(20, 23, 28, .14);
  max-height: 320px; overflow-y: auto; padding: 4px;
}
.ac-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px; cursor: pointer;
}
.ac-item:hover, .ac-item.active { background: var(--primary-soft); }
.ac-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 14px;
}
.ac-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.ac-main b { font-size: 13.5px; font-weight: 600; }
.ac-main small { color: var(--muted-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }

.thread-list-pane {
  width: 360px;
  background: var(--surface);
  border-top: none;
  border-bottom: none;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.pane-header { display: none; }
.thread-list { overflow-y: auto; flex: 1; }
.loading { padding: 20px; color: var(--muted-2); text-align: center; }

.thread-item { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); cursor: pointer; }
/* przeczytane: ledwo zauważalnie przygaszone tło (jak w Gmailu); nieprzeczytane
   czysto białe. Odcień celowo JAŚNIEJSZY niż wyszukiwarka (--bg #FAF9F6). */
.thread-item:not(.unread) { background: var(--read-bg, #FEFDFB); }
.thread-item:hover { background: var(--bg); }
.thread-item.active { background: var(--primary-soft); }
.thread-item.unread .ti-from, .thread-item.unread .ti-subject { font-weight: 700; }
/* awatar z inicjałami — zaokrąglony kwadracik jak w projekcie */
.avatar {
  width: 27px; height: 27px; border-radius: 8px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; letter-spacing: .02em; user-select: none;
}
.avatar-sm { width: 26px; height: 26px; border-radius: 7px; font-size: 10.5px; }
.msg-who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.msg-who > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ti-top { display: flex; justify-content: space-between; }
.ti-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; font-size: 15.5px; }
.ti-date { color: var(--muted-2); font-size: 11.5px; flex-shrink: 0; font-family: var(--font-mono); }
.ti-subject { margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.ti-snippet { color: var(--muted-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { background: var(--border-soft); border-radius: 10px; padding: 1px 8px; font-size: 11px; color: var(--muted); }
.badge-ok { background: var(--success-soft); color: var(--success); }
.badge-draft { background: var(--warn-soft); color: var(--warn); }
.badge-open { background: var(--primary-soft); color: var(--primary); }
.issue-link { font-size: 13px; font-weight: 500; margin-left: 10px; white-space: nowrap; }
/* pasek akcji opinii (nad polem odpowiedzi) */
.rating-actions {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 20px; border-top: 1px solid var(--border); background: var(--bg);
}
.rating-actions .hint { color: var(--muted); font-size: 12.5px; }
/* wybór motywu kolorów (Ustawienia → Motyw kolorów) */
.theme-grid { display: flex; gap: 14px; flex-wrap: wrap; margin: 10px 0; }
.theme-card {
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
  border: 2px solid var(--border); border-radius: 12px; padding: 14px 16px;
  cursor: pointer; min-width: 180px; font-weight: 400;
}
.theme-card:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.theme-card input { width: auto; }
.theme-swatches { display: flex; gap: 6px; }
.theme-swatch { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--border); }
.theme-name { font-weight: 600; }
.theme-custom-row { display: flex; align-items: center; gap: 10px; }
.theme-custom-row input[type="color"] { width: 44px; height: 30px; padding: 2px; margin: 0; flex-shrink: 0; }

/* foldery własne skrzynki: wiersz checkbox + usuwanie; tworzenie przy zapisie */
.sync-folder-row { display: flex; align-items: center; gap: 6px; }
.sync-folder-row label { margin: 4px 0; }
.folder-del {
  border: none; background: none; cursor: pointer; color: var(--muted-2);
  font-size: 12px; line-height: 1; padding: 3px 6px; border-radius: 5px;
}
.folder-del:hover { color: var(--danger); background: var(--danger-soft); }
.save-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.folder-create-inline { display: inline-flex; align-items: center; gap: 8px; margin-left: 14px; }
.folder-create-inline input[type="text"] { width: 220px; margin-top: 0; }

/* skromne strzałki zmiany kolejności + wyrównanie akcji w tabelach */
.btn-move {
  border: none; background: none; cursor: pointer; color: var(--muted-2);
  font-size: 10px; padding: 2px 4px; line-height: 1; border-radius: 4px;
}
.btn-move:hover { color: var(--primary); background: var(--primary-soft); }
td.ta-right { text-align: right; }

/* zwijane sekcje konfiguracji statusów (Ustawienia → Statusy) */
.status-details {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; margin: 10px 0; background: var(--surface);
}
.status-details summary { cursor: pointer; font-size: 14.5px; }
.status-details summary small { color: var(--muted-2); margin-left: 8px; font-weight: 400; }
.status-details[open] summary { margin-bottom: 8px; }
.status-details.status-new summary { color: var(--primary); }

/* zwijany wybór folderów w edycji reguły */
.folders-details { margin: 14px 0 4px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; background: var(--bg); }
.folders-details summary { cursor: pointer; color: var(--text); }
.folders-details[open] summary { margin-bottom: 8px; }
/* chmurka z prośbą o zmianę oceny (negatywna opinia, jeszcze nie wysłano) */
.rating-request-card {
  width: 100%; display: flex; flex-direction: column; gap: 8px;
  background: var(--warn-soft); border: 1px solid var(--warn-border, #EBD9A9); border-radius: 10px;
  padding: 12px 14px;
}
.rating-request-card .rrc-head { font-size: 13px; color: var(--text); }
.rating-request-card textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-family: var(--font-ui); font-size: 13.5px; resize: vertical;
  background: var(--surface);
}
.rating-request-card .rrc-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* karta zwrotu Allegro (jak w Responso) */
.return-card { display: flex; flex-direction: column; gap: 6px; max-width: 640px; }
.return-card .rc-label {
  font-family: var(--font-mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted-2); margin-top: 2px;
}
.return-card .rc-gap { margin-top: 10px; }
.return-card .rc-grid { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 6px; }
.return-card .rc-right { text-align: right; }
.return-card table.rc-items { border-collapse: collapse; width: 100%; margin: 2px 0 4px; }
.return-card .rc-items td { padding: 7px 0; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.return-card .rc-items td.rc-price { text-align: right; white-space: nowrap; color: var(--muted); }
.return-card .rc-comment { color: var(--muted); }
.return-card .rc-total { text-align: right; margin: 2px 0 4px; }
.return-card .rc-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.return-card .rc-actions a.btn { text-decoration: none; }
.badge-closed { background: var(--border-soft); color: var(--muted); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-customer {
  background: var(--success-soft); color: var(--success); cursor: pointer;
  font-size: 12.5px; padding: 5px 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}

.thread-view-pane {
  flex: 1;
  background: var(--surface);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.thread-empty { margin: auto; color: var(--muted-2); font-size: 16px; }
.thread-content { display: flex; flex-direction: column; height: 100%; }
.thread-header { padding: 14px 20px 8px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.thread-header h2 { margin: 0; font-size: 18px; }
.sellasist-panel { margin: 0 20px 8px; display: flex; flex-direction: column; gap: 6px; }
/* każde źródło (Allegro / Sellasist) jako osobna karta z odstępem */
.ss-bar {
  display: flex; gap: 26px; align-items: center; flex-wrap: wrap; font-size: 13.5px;
  background: var(--orderbar-bg, var(--bg)); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px;
}
.ss-bar b { font-weight: 700; }
.ss-bar .ss-link { margin-left: auto; font-weight: 600; white-space: nowrap; }
.ss-orders { display: none; margin-top: 10px; }
.ss-orders.open { display: block; }
.sellasist-panel h3 { margin: 4px 0 8px; font-size: 13.5px; }
.sellasist-panel .table { font-size: 13px; }
.ss-prods { max-width: 260px; font-size: 12px; color: var(--muted-2); }

.thread-messages { flex: 1; overflow-y: auto; padding: 8px 20px; }
/* wiadomość = nagłówek (awatar + nadawca) NAD dymkiem, jak w projekcie */
.msg-block { margin: 12px 0; }
.msg-block-out { margin-left: 96px; }
.msg { border: 1px solid var(--border); border-radius: 10px; padding: 11px 15px; }
.msg-in { background: var(--surface); }
.msg-out { background: var(--primary-soft); border-color: transparent; }
.msg-draft { background: var(--warn-soft); border-color: var(--warn-border, #EBD9A9); }
/* komunikaty systemowe Allegro w dyskusjach/reklamacjach — pomarańczowe */
.msg-system { background: var(--sys-soft, #FFF4E8); border-color: var(--sys-border, #F3D7B0); }
.msg-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted-2); font-size: 12.5px; margin-bottom: 7px; padding: 0 2px; }
.msg-head b { color: var(--text); font-weight: 700; font-size: 13px; }
.msg-mail { color: var(--muted-2); }
.msg-head > span:last-child { font-family: var(--font-mono); font-size: 11.5px; flex-shrink: 0; }
.msg-text { white-space: pre-wrap; word-break: break-word; }
.msg-html { word-break: break-word; }
.msg-html p { margin: .45em 0; }
.msg-html > :first-child { margin-top: 0; }
.msg-html > :last-child { margin-bottom: 0; }
.msg-html img { max-width: 100%; }
.msg-translation { margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 6px; }
.msg-translation summary { cursor: pointer; color: var(--primary); }
.draft-actions { margin-top: 8px; }

/* pole odpowiedzi */
.reply-box { border-top: 1px solid var(--border); padding: 12px 20px 16px; background: var(--reply-bg, var(--bg)); }
.reply-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.reply-toggles { margin-left: auto; display: flex; gap: 16px; }
.reply-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
#send-status, #compose-status { color: var(--muted-2); }

/* suwak (switch) */
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 400; font-size: 13px; margin: 0; color: var(--muted); }
.switch input { display: none; }
.switch .slider {
  width: 34px; height: 18px; background: var(--switch-bg, #DAD6CB); border-radius: 10px; position: relative; transition: .2s;
}
.switch .slider::after {
  content: ''; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; top: 2px; left: 2px; transition: .2s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::after { left: 18px; }

/* AI: podpowiedzi + czat */
.ai-suggest, .ai-chat { border: 1px solid var(--border); border-radius: 12px; margin-top: 10px; padding: 11px 15px; background: var(--surface); }
.ai-suggest-head, .ai-chat-head { font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.ai-suggest-head svg, .ai-chat-head svg { color: var(--primary); }
.ai-suggest-body { white-space: pre-wrap; color: var(--text); margin-bottom: 6px; }
.ai-suggest .link-btn { font-weight: 600; }
.ai-chat-log { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.chat-msg { padding: 6px 10px; border-radius: 10px; max-width: 85%; white-space: pre-wrap; }
.chat-user { background: var(--primary-soft); align-self: flex-end; }
.chat-assistant { background: var(--border-soft); align-self: flex-start; }
.chat-use { border: none; background: none; cursor: pointer; color: var(--primary); }
.ai-chat-input { display: flex; gap: 8px; }
.ai-chat-input input { margin-top: 0; }

/* modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(20,23,28,.4);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal { background: var(--surface); border-radius: 14px; padding: 20px 24px; width: 560px; max-width: 94vw; max-height: 90vh; overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; font-weight: 700; font-size: 16px; margin-bottom: 8px; }
.modal-close { border: none; background: none; font-size: 16px; cursor: pointer; color: var(--muted); }

/* ---------- Wybór dostawcy integracji ---------- */

.provider-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; max-width: 900px; }
.provider-card {
  border: 1px solid var(--border); border-radius: 12px; padding: 20px; text-align: center;
  color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--surface);
}
.provider-card:hover { text-decoration: none; border-color: var(--primary); box-shadow: 0 1px 6px rgba(20,23,28,.08); }
.provider-card.disabled { opacity: .55; }
.provider-card .provider-icon { font-size: 32px; }
.provider-card h3 { margin: 4px 0; }
.provider-card p { color: var(--muted); font-size: 13px; margin: 0 0 8px; }

/* ---------- Odbiorcy Do/DW w odpowiedzi ---------- */

.reply-mode { display: flex; gap: 6px; }
.reply-recipients { margin-bottom: 6px; }
.recipient-row { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 4px 0; }
.recipient-row input { margin-top: 0; }
.link-btn { border: none; background: none; color: var(--primary); cursor: pointer; padding: 0; font-size: 13px; font-family: var(--font-ui); }
.msg-recipients { color: var(--muted-2); font-size: 12px; margin-bottom: 4px; }

/* ---------- Załączniki ---------- */

.msg-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 8px; }
.att-chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--border); border-radius: 8px; padding: 4px 12px;
  color: var(--text); font-size: 13px; max-width: 280px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; background: var(--surface);
}
.att-chip:hover { text-decoration: none; border-color: var(--primary); }
.att-chip small { color: var(--muted-2); }
.att-chip .att-name { overflow: hidden; text-overflow: ellipsis; }

/* plakietka typu pliku (PDF czerwona, DOC niebieska, XLS zielona...) */
.att-ext {
  flex-shrink: 0; font-size: 9.5px; font-weight: 800; letter-spacing: .04em;
  border-radius: 5px; padding: 3px 6px; color: #fff; font-family: var(--font-mono);
}
.att-ext-pdf  { background: #D93025; }
.att-ext-doc  { background: #1A73E8; }
.att-ext-xls  { background: #188038; }
.att-ext-ppt  { background: #E8710A; }
.att-ext-zip  { background: #7B5EA7; }
.att-ext-txt  { background: #5F6368; }
.att-ext-file { background: #80868B; }

/* zablokowany załącznik (opcja bezpieczeństwa skrzynki) */
.att-blocked {
  border-style: dashed; color: var(--muted-2); cursor: help; background: var(--bg);
}

/* miniaturki obrazków z powiększeniem */
.msg-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.msg-thumbs img {
  height: 110px; max-width: 180px; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--border); display: block;
}
.msg-thumbs .att-thumb:hover img { border-color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,.12); }

#lightbox {
  position: fixed; inset: 0; z-index: 300; display: none;
  align-items: center; justify-content: center; cursor: zoom-out;
  background: rgba(10, 10, 8, .82);
}
#lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; box-shadow: 0 8px 40px rgba(0,0,0,.5); }

/* zwinięta cytowana historia (jak w Gmailu) */
.quote-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--bg); color: var(--muted);
  border-radius: 8px; padding: 0 8px; height: 14px; line-height: 1;
  cursor: pointer; margin: 4px 0 0; font-size: 12px; letter-spacing: 1.5px;
}
.quote-toggle:hover { background: var(--border-soft); color: var(--text); }
.msg-quote {
  border-left: 3px solid var(--border); margin-top: 6px; padding-left: 10px;
  color: var(--muted);
}

/* wybrane pliki przed wysyłką */
.attach-list { display: flex; flex-wrap: wrap; gap: 6px; }
.attach-list:not(:empty) { margin: 8px 0 2px; }
.att-pick {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 8px; padding: 3px 8px;
  font-size: 12.5px; background: var(--surface);
}
.att-pick small { color: var(--muted-2); }
.att-pick button { border: none; background: none; cursor: pointer; color: var(--muted-2); padding: 0 2px; }
.att-pick button:hover { color: #D93025; }

/* ---------- Pasek akcji listy + zaznaczanie + gwiazdki ---------- */

.list-toolbar {
  display: flex; align-items: center; gap: 3px;
  padding: 7px 8px; border-bottom: 1px solid var(--border);
  flex-wrap: nowrap; background: var(--toolbar-bg, var(--bg)); /* jeden rząd — ikony się nie łamią */
}
.list-toolbar .toolbar-checkall { margin: 0 2px; flex-shrink: 0; }
.list-toolbar .icon-btn { flex-shrink: 0; }
.list-toolbar .btn-sm { border-radius: 7px; padding: 4px 9px; font-size: 12px; }
.list-toolbar select {
  width: auto; padding: 4px 4px; margin: 0; font-size: 12px; border-radius: 7px;
  flex: 0 1 auto; min-width: 0; max-width: 118px; /* zwęża się zamiast spychać ikony */
  overflow: hidden; text-overflow: ellipsis;
}
.toolbar-count {
  margin-left: auto; color: var(--muted-2); font-size: 12px; padding-right: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; min-width: 0;
}

.folder-unread {
  background: var(--badge-folder-bg, var(--primary)); color: var(--badge-folder-fg, #fff); border-radius: 10px;
  font-size: 11px; padding: 0 7px; margin-left: auto; font-family: var(--font-mono);
}
.ti-row { display: flex; align-items: flex-start; gap: 8px; }
/* kolumna awatar + gwiazdka pod spodem — więcej miejsca na treść wiersza */
.ti-side { display: flex; flex-direction: column; align-items: center; gap: 3px; flex-shrink: 0; }
.ti-check { margin-top: 4px; flex-shrink: 0; }
.ti-star { cursor: pointer; flex-shrink: 0; margin-top: 2px; line-height: 0; color: var(--muted-2); }
.ti-star svg { fill: none; stroke: var(--muted-2); }
.ti-star.starred svg { fill: #F4B400; stroke: #F4B400; }
.ti-star:hover { transform: scale(1.12); }
.ti-main { flex: 1; min-width: 0; cursor: pointer; }

/* responsywność */
@media (max-width: 1000px) {
  .inbox-layout { flex-direction: column; height: auto; }
  .inbox-sidebar, .thread-list-pane { width: 100%; }
  .thread-list { max-height: 40vh; }
  .settings-wrap { flex-direction: column; }
  .settings-nav { width: 100%; }
  .auth-split { flex-direction: column; }
  .auth-left { flex: none; padding: 26px 24px; gap: 20px; }
  .auth-quote { font-size: 20px; }
  .hero h1 { font-size: 32px; }
}
