*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg: #ffffff;
  --surface: #f8f8f8;
  --surface2: #f0f0f0;
  --border: #e2e2e2;
  --accent: #cc0000;
  --accent2: #059669;
  --success: #059669;
  --danger: #cc0000;
  --warn: #d97706;
  --text: #111111;
  --text2: #555e6e;
  --radius: 8px;
}

body { background: var(--bg); color: var(--text); font: 14px/1.6 system-ui, sans-serif; }

/* ── Skip link ── */
.skip-link {
  position: absolute; left: -9999px; top: 4px; z-index: 999;
  padding: 8px 16px; background: var(--accent); color: #fff;
  border-radius: var(--radius); font-size: 14px; font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { left: 4px; }

/* ── Screen-reader only ── */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Global focus-visible ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* Inputs use box-shadow approach — suppress outline there */
.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible,
.search-row input:focus-visible {
  outline: none;
}

/* ── Login ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
  /* Fallback gradient — widoczny zanim załadują się zdjęcia */
  background: linear-gradient(135deg, #1a1a2e 0%, #2d2d4e 50%, #1a1a2e 100%);
}
.login-bg {
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity .8s ease;
  z-index: 0;
}
.login-bg.loaded { opacity: 1; }
.login-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, rgba(0,0,0,.55) 0%, rgba(0,0,0,.38) 100%);
  z-index: 1;
}
.login-page > main {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  justify-content: center;
}
.login-box {
  background: rgba(255,255,255,.10);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 20px;
  padding: 48px 44px 44px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 16px 56px rgba(0,0,0,.35), 0 2px 8px rgba(0,0,0,.15);
}
.logo { text-align: center; margin-bottom: 36px; }
.logo h1 {
  font-size: 28px; font-weight: 800; margin-bottom: 8px;
  color: #fff; letter-spacing: -.5px;
  text-shadow: 0 1px 6px rgba(0,0,0,.3);
}
.logo p { color: rgba(255,255,255,.75); font-size: 14px; min-height: 1.4em; transition: color .2s; }
#loginTagline.success { color: #fff; font-weight: 700; font-size: 15px; }

/* Login page — scoped field overrides */
.login-page .field label { color: rgba(255,255,255,.9); }
.login-page .field input {
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.35);
  color: #fff;
}
.login-page .field input::placeholder { color: rgba(255,255,255,.45); }
.login-page .field input:focus {
  outline: none;
  border-color: rgba(255,255,255,.65);
  box-shadow: 0 0 0 3px rgba(255,255,255,.12);
  background: rgba(255,255,255,.24);
}
.login-page .error-msg {
  background: rgba(180,0,0,.30);
  color: #fff;
  border: 1px solid rgba(255,120,120,.4);
}
.login-page .btn-primary {
  margin-top: 6px;
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .3px;
}

/* ── Form ── */
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text2); font-weight: 500; }
.assignees-list {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 4px; background: var(--surface);
}
.assignees-list label {
  display: flex !important; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: 4px;
  cursor: pointer; font-size: 13px; color: var(--text);
  font-weight: 400; margin-bottom: 0; transition: background .12s;
  width: 100%; box-sizing: border-box;
}
.assignees-list label:hover { background: var(--surface2); }
.assignees-list label input[type=checkbox] { flex-shrink: 0; width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.assignees-list label span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.assignees-list__empty { display: block; padding: 6px 10px; color: var(--text2); font-size: 12px; }
.assignees-pin-btn {
  flex-shrink: 0; background: none; border: none; padding: 2px 3px;
  cursor: pointer; color: var(--text2); border-radius: 3px;
  line-height: 1; display: flex; align-items: center;
  transition: color .12s, background .12s;
}
.assignees-pin-btn:hover { background: var(--surface2); color: var(--text); }
.assignees-pin-btn.pinned { color: var(--accent); }
.assignees-expand-btn {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 5px 10px; font-size: 12px; color: var(--accent); cursor: pointer;
  border-radius: 4px; margin-top: 2px; transition: background .12s;
}
.assignees-expand-btn:hover { background: var(--surface2); }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 14px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(204,0,0,.08);
}

/* ── Buttons ── */
.btn-primary, .btn-secondary, .btn-danger, .btn-sm {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius); border: none;
  font-size: 14px; cursor: pointer; font-weight: 500; transition: all .15s;
}
.btn-primary { background: var(--accent); color: #fff; width: 100%; justify-content: center; }
.btn-primary:hover { background: #a80000; }
.btn-primary:disabled { background: #e5a3a3; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-secondary:disabled { opacity: .5; cursor: not-allowed; }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #f5c6c6; }
.btn-danger:hover { background: #fff5f5; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.btn-success:hover { background: #a7f3d0; }

.error-msg { background: #fff5f5; color: var(--danger); border: 1px solid #fca5a5;
             padding: 10px 12px; border-radius: var(--radius); margin-top: 12px; font-size: 13px; }

/* ── Mobile header (visible only on mobile) ── */
.mobile-header {
  display: none;
  align-items: center; justify-content: space-between;
  padding: 0 16px; height: 48px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.mobile-header .brand { font-size: 16px; font-weight: 700; color: var(--text); }
.mobile-menu-btn {
  background: none; border: none; cursor: pointer; color: var(--text);
  padding: 8px; font-size: 22px; line-height: 1; display: flex; align-items: center;
}

/* ── App Layout ── */
.app-layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 220px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
  min-height: 0; overflow: hidden;
}
.sidebar-logo { padding: 20px 16px 12px; border-bottom: none; flex-shrink: 0; }
.sidebar-logo span { font-size: 18px; font-weight: 700; color: var(--text); }
.sidebar-logo strong { display: block; color: var(--text); font-size: 12px; font-weight: 700; margin-top: 3px; }
.sidebar-quote {
  margin: 0 12px 10px;
  padding: 8px 12px 8px 14px;
  background: #fff5f5;
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  font-size: 11px;
  color: var(--text2);
  line-height: 1.5;
  font-style: italic;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 0;
  border-radius: 0 6px 0 0;
}
.sidebar-quote:empty { display: none; }
.sidebar nav { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 0; }

/* nav-item as button — reset + restyle */
button.nav-item {
  all: unset;
  box-sizing: border-box;
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  color: var(--text2); cursor: pointer; transition: all .15s; font-size: 13px;
  border-left: 3px solid transparent; width: 100%;
}
button.nav-item:hover { color: var(--text); background: var(--surface2); }
button.nav-item.active { color: var(--accent); background: #fff5f5; border-left-color: var(--accent); font-weight: 600; }
button.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text2); flex-shrink: 0; }
.app-version { margin-top: 8px; font-size: 10px; color: var(--text2); opacity: .7; line-height: 1.5; }
.app-version a { color: inherit; text-decoration: none; }
.app-version a:hover { text-decoration: underline; }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 59; cursor: pointer;
}

.main-content { flex: 1; overflow-y: auto; padding: 24px; background: var(--bg); }

/* ── Pages ── */
.page { display: none; }
.page.active { display: block; }
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 20px; font-weight: 700; color: var(--text); }
.page-header p { color: var(--text2); font-size: 13px; margin-top: 4px; }

/* ── Cards ── */
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
        box-shadow: 0 1px 4px rgba(0,0,0,.04); }
.card-head { padding: 14px 20px; border-bottom: 1px solid var(--border);
             display: flex; align-items: center; justify-content: space-between; }
.card-head h3 { font-size: 14px; font-weight: 600; color: var(--text); }
.card-body { padding: 20px; }

/* ── Account list ── */
.account-list { display: flex; flex-direction: column; gap: 10px; }
.account-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
                padding: 14px 18px; display: flex; align-items: center; gap: 12px;
                box-shadow: 0 1px 3px rgba(0,0,0,.04); flex-wrap: wrap; }
.account-card:hover { border-color: #ccc; }
.account-card.selected { border-color: var(--accent); }
.account-card--default { border-color: var(--accent); background: #fff9f9; }
.acc-default-star { color: var(--accent); font-size: 13px; }
.acc-name { font-weight: 600; font-size: 14px; color: var(--text); }
.acc-meta { color: var(--text2); font-size: 12px; }
/* Improved contrast: was #6b7280 on #f0f0f0 ≈ 3.5:1 → now #374151 on #f0f0f0 ≈ 6.9:1 */
.acc-badge { background: var(--surface2); border: 1px solid var(--border); border-radius: 20px;
             padding: 2px 10px; font-size: 11px; color: #374151; white-space: nowrap; }
.acc-badge.synced { border-color: #a7f3d0; color: #065f46; background: #ecfdf5; }

/* ── Stats grid ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-box { background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
            padding: 14px 16px; }
.stat-box .stat-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; }
.stat-box .stat-value { font-size: 22px; font-weight: 700; margin-top: 4px; color: var(--text); }

/* ── Progress ── */
.progress-bar { background: var(--surface2); border-radius: 4px; height: 6px; overflow: hidden; margin: 8px 0; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
                border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.status-badge.running  { background: #dbeafe; color: #1d4ed8; }
.status-badge.completed { background: #dcfce7; color: #16a34a; }
.status-badge.failed   { background: #fee2e2; color: #dc2626; }
.status-badge.pending  { background: var(--surface2); color: #374151; }
.status-badge.stopped  { background: #fff7ed; color: #c2410c; }

/* ── Log console (intentionally dark) ── */
.log-console { background: #1a1a1a; border: 1px solid #333; border-radius: var(--radius);
               padding: 12px; font-family: 'Fira Code', monospace; font-size: 12px;
               height: 300px; overflow-y: auto; line-height: 1.8; }
.log-line { display: flex; gap: 8px; }
.log-line .ts  { color: #888; flex-shrink: 0; }
.log-line .mod { color: #a78bfa; flex-shrink: 0; min-width: 120px; }
.log-line.info  .msg { color: #d1d5db; }
.log-line.warn  .msg { color: #fbbf24; }
.log-line.error .msg { color: #f87171; }

/* ── Table ── */
.data-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead tr { border-bottom: 2px solid var(--border); }
th { padding: 10px 12px; text-align: left; color: var(--text2); font-weight: 600;
     text-transform: uppercase; font-size: 10px; letter-spacing: .5px; white-space: nowrap; background: var(--surface); }
td { padding: 9px 12px; border-bottom: 1px solid var(--border); color: var(--text);
     max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr:hover td { background: #fff8f8; }

/* ── Module picker ── */
.module-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
/* module-pill as button */
button.module-pill {
  all: unset;
  box-sizing: border-box;
  padding: 5px 12px; border-radius: 20px; font-size: 12px; cursor: pointer;
  background: #fff; border: 1px solid var(--border); color: var(--text2);
  transition: all .15s;
}
button.module-pill:hover,
button.module-pill.active { border-color: var(--accent); color: var(--accent); background: #fff5f5; }
button.module-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.module-pill .cnt { opacity: .7; }

/* ── Search bar ── */
.search-row { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.search-row input { flex: 1; min-width: 160px; padding: 8px 12px; background: #fff;
                    border: 1px solid var(--border); border-radius: var(--radius);
                    color: var(--text); font-size: 13px; }
.search-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(204,0,0,.08); }
.pagination { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.pagination span { color: var(--text2); font-size: 12px; }

/* ── Modal ── */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex;
            align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-bg.hidden { display: none; }
.modal { background: #fff; border: 1px solid var(--border); border-radius: 12px;
         width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
         box-shadow: 0 8px 32px rgba(0,0,0,.15); }
.modal-head { padding: 18px 24px; border-bottom: 1px solid var(--border);
              display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text2); font-size: 20px;
               cursor: pointer; padding: 4px 8px; border-radius: 4px; line-height: 1; }
.modal-close:hover { color: var(--text); background: var(--surface2); }
.modal-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.modal-body { padding: 24px; }
.task-creator-bar { padding: 7px 24px; background: var(--surface2); border-bottom: 1px solid var(--border);
                    font-size: 12px; color: var(--text2); }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--border); display: flex;
              justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* ── Analysis ── */
.mode-tabs { display: flex; gap: 3px; background: var(--surface2); padding: 3px; border-radius: var(--radius); }
.mode-tab { padding: 6px 16px; border-radius: 6px; border: none; background: none;
            color: var(--text2); font-size: 13px; cursor: pointer; transition: all .15s; font-weight: 500; }
.mode-tab:hover { color: var(--text); background: #fff; }
.mode-tab.active { background: var(--accent); color: #fff; }
.mode-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.template-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.tpl-pill { padding: 4px 12px; border-radius: 20px; font-size: 12px; cursor: pointer;
            background: #fff; border: 1px solid var(--border); color: var(--text2);
            transition: all .15s; }
.tpl-pill:hover { border-color: var(--accent); color: var(--accent); background: #fff5f5; }
.tpl-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Account select (reusable inline select) ── */
.inline-select {
  padding: 6px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 13px;
  min-width: 0; max-width: 100%; height: 34px;
}
.inline-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(204,0,0,.08); }
.analysis-textarea {
  width: 100%; padding: 10px 12px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 14px; resize: vertical;
  box-sizing: border-box; font-family: inherit; line-height: 1.5;
}
.analysis-textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(204,0,0,.08); }
.inline-input {
  padding: 6px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 13px;
  min-width: 0; height: 34px;
}
.inline-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(204,0,0,.08); }
.inline-input::placeholder { color: var(--text2); }

/* ── Tasks toolbar ── */
.tasks-toolbar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.tasks-date-filter {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.task-date-btn {
  padding: 5px 12px; font-size: 12px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; color: var(--text2); cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.task-date-btn:hover { background: var(--surface2); color: var(--text); }
.task-date-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tasks-selects {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.tasks-selects-right {
  display: flex; gap: 8px; align-items: center; margin-left: auto; flex-shrink: 0;
}
@media (max-width: 640px) {
  .tasks-selects { flex-direction: column; align-items: stretch; }
  .tasks-selects-right { margin-left: 0; flex-wrap: wrap; }
  .tasks-selects-right .btn-primary { flex: 1; }
  .task-view-toggle { flex: 1; }
  .task-view-btn { flex: 1; text-align: center; }
  .inline-select, .inline-input { width: 100%; }
}

/* ── Autocomplete ── */
.autocomplete-dropdown.hidden { display: none; }
.autocomplete-dropdown { position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  max-height: 220px; overflow-y: auto; margin-top: 2px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.autocomplete-item { padding: 9px 14px; cursor: pointer; font-size: 13px;
                     border-bottom: 1px solid var(--surface2); }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item[aria-selected="true"] { background: #fff5f5; }
.autocomplete-item small { color: var(--text2); font-size: 11px; display: block; }

.selected-company { background: #fff5f5; border: 1px solid #fca5a5;
  border-radius: var(--radius); padding: 10px 14px; font-size: 13px; }
.selected-company .sc-name { font-weight: 600; color: var(--text); }
.selected-company .sc-id { color: var(--text2); font-size: 11px; margin-top: 2px; }

/* ── Markdown ── */
.markdown-body { font-size: 14px; line-height: 1.7; color: var(--text); }
.markdown-body h1, .markdown-body h2 { font-size: 16px; font-weight: 600; margin: 16px 0 8px;
  padding-bottom: 6px; border-bottom: 2px solid var(--accent); color: var(--text); }
.markdown-body h3 { font-size: 14px; font-weight: 600; margin: 12px 0 6px; color: var(--text); }
.markdown-body ul, .markdown-body ol { padding-left: 20px; margin: 8px 0; }
.markdown-body li { margin: 4px 0; }
.markdown-body p { margin: 8px 0; }
.markdown-body strong { color: var(--accent); }
.markdown-body code { background: var(--surface2); padding: 1px 6px; border-radius: 4px;
  font-family: monospace; font-size: 12px; color: var(--text); }
.markdown-body pre { background: var(--surface2); padding: 12px; border-radius: var(--radius);
  overflow-x: auto; margin: 10px 0; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.markdown-body table.md-table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.markdown-body table.md-table th { background: var(--surface2); padding: 8px 12px; text-align: left;
  font-weight: 600; border: 1px solid var(--border); color: var(--text);
  text-transform: none; letter-spacing: normal; font-size: 13px; white-space: nowrap; }
.markdown-body table.md-table td { padding: 7px 12px; border: 1px solid var(--border);
  color: var(--text); background: #fff; white-space: normal; max-width: none;
  overflow: visible; text-overflow: initial; }
.markdown-body table.md-table tr:nth-child(even) td { background: var(--surface); }

/* ── Analysis log cards ── */
.analysis-log-card { background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px; cursor: pointer;
  transition: border-color .15s; width: 100%; text-align: left; }
.analysis-log-card:hover { border-color: var(--accent); background: #fff5f5; }
.analysis-log-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.analysis-log-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.analysis-log-tag { background: var(--surface2); padding: 2px 8px; border-radius: 10px;
  font-size: 11px; color: #374151; }
.analysis-log-vis { display: flex; align-items: center; gap: 6px; margin-top: 8px;
  padding-top: 8px; border-top: 1px solid var(--border); }
.analysis-log-vis input[type=checkbox] { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; }
.analysis-log-vis label { font-size: 11px; color: var(--text2); cursor: pointer; user-select: none; }

/* ── Toast ── */
#toast { position: fixed; bottom: 24px; right: 24px; background: #fff;
         border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 18px;
         font-size: 13px; z-index: 200; transition: opacity .3s;
         box-shadow: 0 4px 16px rgba(0,0,0,.1); max-width: calc(100vw - 48px); }
#toast.hidden { opacity: 0; pointer-events: none; }
#toast.ok  { border-left: 4px solid #16a34a; color: var(--text); }
#toast.err { border-left: 4px solid var(--danger); color: var(--text); }

/* ── Steps toggle button ── */
#stepsToggle { cursor: pointer; }
#stepsToggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ── Users tabs (reuse mode-tabs pattern) ── */
.users-tabs { display: flex; gap: 3px; background: var(--surface2); padding: 3px; border-radius: var(--radius); margin-bottom: 20px; }
.users-tab { padding: 6px 16px; border-radius: 6px; border: none; background: none;
             color: var(--text2); font-size: 13px; cursor: pointer; transition: all .15s; font-weight: 500; }
.users-tab:hover { color: var(--text); background: #fff; }
.users-tab.active { background: var(--accent); color: #fff; }
.users-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── User table ── */
.users-table td .user-fullname { font-weight: 600; font-size: 13px; }
.users-table td .user-username { color: var(--text2); font-size: 11px; }
.role-badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.role-badge.admin { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.role-badge.owner { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }
.role-badge.user  { background: var(--surface2); color: #374151; border: 1px solid var(--border); }

/* ── Activity log ── */
.action-badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px;
                white-space: nowrap; background: var(--surface2); color: #374151; border: 1px solid var(--border); }
.action-badge.login, .action-badge.logout   { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.action-badge.analysis_brief,
.action-badge.analysis_portfolio            { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.action-badge.sync_start, .action-badge.sync_resume { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.action-badge.sync_stop                     { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.action-badge.export_json, .action-badge.export_csv { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.action-badge.task_create, .action-badge.task_update,
.action-badge.task_status, .action-badge.task_delete { background: #fdf2f8; color: #9d174d; border-color: #fbcfe8; }

/* ── User tiles ── */
.user-tiles-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.user-tile {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.user-tile-name { font-weight: 700; font-size: 14px; color: var(--text); }
.user-tile-role { font-size: 11px; color: var(--text2); margin-top: -4px; }
.user-tile-ops  { font-size: 12px; color: var(--text2); padding-top: 6px; border-top: 1px solid var(--border); }
.user-tile-ops strong { color: var(--text); font-size: 18px; font-weight: 700; }
.user-tile-tasks { display: flex; flex-direction: column; gap: 5px; }
.user-tile-stat { display: grid; grid-template-columns: 80px 1fr 24px; align-items: center; gap: 6px; }
.user-tile-stat-label { font-size: 11px; color: var(--text2); white-space: nowrap; }
.user-tile-stat-bar-wrap { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.user-tile-stat-bar { height: 100%; border-radius: 4px; transition: width .3s ease; min-width: 2px; }
.user-tile-stat-num { font-size: 12px; font-weight: 700; color: var(--text); text-align: right; }
.user-tile-stat.planned      .user-tile-stat-bar { background: #818cf8; }
.user-tile-stat.in_progress  .user-tile-stat-bar { background: #fbbf24; }
.user-tile-stat.done_pending .user-tile-stat-bar { background: #fb923c; }
.user-tile-stat.done         .user-tile-stat-bar { background: #4ade80; }
.tiles-range.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Kanban board ── */
/* ── Task view toggle ── */
.user-blocked-badge { display: inline-flex; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.user-block-btn { color: var(--warn) !important; border-color: var(--warn) !important; }
tr.user-row-blocked td { opacity: .6; }
tr.user-row-blocked .user-fullname { text-decoration: line-through; color: var(--text2); }

.task-view-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; flex-shrink: 0; }
.task-view-btn { background: none; border: none; border-right: 1px solid var(--border); padding: 5px 13px; font-size: 12px; color: var(--text2); cursor: pointer; transition: background .15s, color .15s; white-space: nowrap; }
.task-view-btn:last-child { border-right: none; }
.task-view-btn.active { background: var(--accent); color: #fff; }
.task-view-btn:hover:not(.active) { background: var(--surface2); color: var(--text); }

/* ── Task table ── */
#taskTableWrap { margin-top: 16px; display: flex; flex-direction: column; gap: 16px; }
.task-table-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.task-table-section-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 13px;
  border-left: 4px solid transparent; background: var(--surface2);
}
.task-table-empty { color: var(--text2); font-size: 12px; text-align: center; padding: 16px; margin: 0; }
.task-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.task-table th { text-align: left; padding: 8px 14px; border-bottom: 1px solid var(--border); font-weight: 600; color: var(--text2); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; background: var(--bg); }
.task-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.task-table tbody tr:last-child td { border-bottom: none; }
.task-table tbody tr:hover td { background: #fafafa; }
.task-table-desc { font-size: 12px; color: var(--text2); max-width: 240px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-table-overdue { color: var(--danger); font-weight: 600; }
.task-table-att { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--accent); font-weight: 500; }
.task-table-assignee { font-size: 12px; color: var(--text2); }
.task-table .task-priority-dot { display: inline-block; margin-right: 5px; vertical-align: middle; }

/* ── Task status badges for table ── */
.task-status-badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 10px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.task-status-badge.planned      { background: #ede9fe; color: #5b21b6; }
.task-status-badge.in_progress  { background: #fff7ed; color: #c2410c; }
.task-status-badge.done_pending { background: #fff3e0; color: #e65100; }
.task-status-badge.done         { background: #dcfce7; color: #15803d; }

.kanban-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 16px; align-items: start; }
.kanban-board.has-pending { grid-template-columns: repeat(4, 1fr); }
.kanban-col { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); }
.kanban-col-head {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 13px; display: flex; align-items: center; justify-content: space-between;
  border-top: 3px solid var(--border); border-radius: var(--radius) var(--radius) 0 0;
}
.kanban-col.planned      .kanban-col-head { border-top-color: #6366f1; }
.kanban-col.in_progress  .kanban-col-head { border-top-color: var(--warn); }
.kanban-col.done_pending .kanban-col-head { border-top-color: #f97316; }
.kanban-col.done         .kanban-col-head { border-top-color: var(--accent2); }
.badge-pending { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa;
                 padding: 1px 7px; border-radius: 10px; font-size: 10px; font-weight: 600; }
.task-notes { background: #fffbeb; border-left: 3px solid #f59e0b; padding: 6px 10px;
              font-size: 11px; color: #78350f; border-radius: 0 4px 4px 0; margin-top: 6px; }
.kanban-count { background: #fff; border: 1px solid var(--border); border-radius: 10px;
                padding: 1px 8px; font-size: 12px; color: var(--text2); }
.kanban-col-body { padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 120px; }
.kanban-empty { color: var(--text2); font-size: 12px; text-align: center; padding: 20px 0; }
.kanban-more-btn { display: block; width: calc(100% - 20px); margin: 4px 10px 10px; padding: 7px; font-size: 12px; color: var(--accent); background: none; border: 1px dashed var(--border); border-radius: 6px; cursor: pointer; transition: background .15s; }
.kanban-more-btn:hover { background: var(--surface2); }

.task-table-section-head { gap: 8px; justify-content: flex-start; }
.task-section-arrow { margin-left: auto; font-size: 10px; color: var(--text2); }

/* ── Task card ── */
.task-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
             padding: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.04); transition: border-color .15s; }
.task-card:hover { border-color: #ccc; }
.task-card-top { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.task-priority-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.task-priority-dot.high   { background: var(--danger); }
.task-priority-dot.medium { background: var(--warn); }
.task-priority-dot.low    { background: var(--accent2); }
.task-title { font-weight: 600; font-size: 13px; line-height: 1.4; color: var(--text); }
.task-desc { font-size: 12px; color: var(--text2); margin-bottom: 8px; line-height: 1.4;
             display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-meta { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.task-meta-row { font-size: 11px; color: var(--text2); display: flex; align-items: center; gap: 5px; }
.task-meta-icon { font-size: 12px; }
.task-due-overdue { color: var(--danger) !important; font-weight: 600; }
.task-actions { display: flex; gap: 5px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 8px; }
.task-actions .btn-sm { flex: 1; justify-content: center; font-size: 11px; padding: 4px 6px; }

/* ── Chips (multi-select companies/users in modal) ── */
.chips-input-wrap { position: relative; }
.chips-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; min-height: 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: #fff5f5;
        border: 1px solid #fca5a5; border-radius: 20px; padding: 3px 10px;
        font-size: 12px; color: var(--text); }
.chip-remove { background: none; border: none; color: var(--text2); cursor: pointer;
               font-size: 13px; padding: 0; line-height: 1; }
.chip-remove:hover { color: var(--danger); }

/* ── Pływający przycisk zgłoszenia ── */
.bug-float-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 150;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(204,0,0,.35), 0 2px 6px rgba(0,0,0,.15);
  transition: transform .15s, box-shadow .15s;
  touch-action: none;
  user-select: none;
}
.bug-float-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(204,0,0,.45), 0 2px 8px rgba(0,0,0,.18);
}
.bug-float-btn:active { transform: scale(.96); }
.bug-float-btn.dragging { opacity: .85; transform: scale(1.04); cursor: grabbing; }

/* ── Zgłoszenia — karty ── */
.report-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.report-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.report-card-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.report-card-id { font-size: 11px; color: var(--text2); flex-shrink: 0; }
.report-card-user { font-weight: 600; font-size: 13px; }
.report-card-date { font-size: 11px; color: var(--text2); margin-left: auto; white-space: nowrap; }
.report-card-desc {
  font-size: 13px; color: var(--text2); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.report-card-footer { margin-top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.status-badge.nowy      { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.status-badge.w_trakcie { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.status-badge.zamkniety { background: #f0fdf4; color: #15803d; border: 1px solid #86efac; }

.reports-filter.active  { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Responsive (mobile ≤ 767px) ── */
@media (max-width: 767px) {
  .mobile-header { display: flex; }

  .app-layout { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
    transform: translateX(-100%); transition: transform .25s ease;
    width: min(280px, 85vw); height: 100%;
  }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-open .sidebar-overlay { display: block; }

  .main-content { padding: 16px; overflow-y: visible; overflow-x: hidden; flex: none; }

  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }

  .mode-tabs { width: 100%; }
  .mode-tab { flex: 1; text-align: center; }

  .inline-select { width: 100%; }

  .card-head { flex-wrap: wrap; gap: 8px; }
  .modal-foot { justify-content: stretch; }
  .modal-foot button { flex: 1; justify-content: center; }

  .login-box { padding: 32px 24px; border-radius: 14px; }
  .logo h1 { font-size: 22px; }
  .logo p { font-size: 13px; }
  .kanban-board { grid-template-columns: 1fr; }
  .user-tiles-grid { grid-template-columns: repeat(2, 1fr); }
  .task-table-desc { max-width: 140px; }
}

/* ── Batch brief status badges ── */
.batch-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 10px; font-size: 11px; font-weight: 600;
}
.batch-badge.pending  { background: var(--surface2); color: var(--text2); }
.batch-badge.running  { background: #dbeafe; color: #1d4ed8; }
.batch-badge.done     { background: #dcfce7; color: #15803d; }
.batch-badge.error    { background: #fee2e2; color: #b91c1c; }
.batch-badge.running::before {
  content: '';
  width: 8px; height: 8px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#batchProgressBody tr { border-bottom: 1px solid var(--border); }
#batchProgressBody tr:last-child { border-bottom: none; }
#batchProgressBody td { padding: 8px 12px; vertical-align: middle; }
#batchProgressBody tr.batch-row-running { background: #eff6ff; }
#batchProgressBody tr.batch-row-done    { background: #f0fdf4; }
#batchProgressBody tr.batch-row-error   { background: #fff1f2; }

/* ── Settings tabs ── */
.settings-tabs { display: flex; gap: 2px; margin-bottom: 20px; border-bottom: 2px solid var(--border); }
.settings-tab { background: none; border: none; padding: 8px 18px; font-size: 13px; font-weight: 600; color: var(--text2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color .15s; }
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── AI Logs tables ── */
.ai-logs-summary-table, .ai-logs-detail-table {
  width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.ai-logs-summary-table th, .ai-logs-detail-table th {
  text-align: left; padding: 8px 14px; background: var(--surface2);
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.ai-logs-summary-table td, .ai-logs-detail-table td {
  padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.ai-logs-summary-table tbody tr:last-child td,
.ai-logs-detail-table tbody tr:last-child td { border-bottom: none; }
.ai-logs-summary-table tbody tr:hover td,
.ai-logs-detail-table tbody tr:hover td { background: #fafafa; }
.ai-logs-summary-table tfoot td { border-top: 2px solid var(--border); border-bottom: none; background: var(--surface2); }

/* ── Responsive (tablet 768–1023px) ── */
@media (min-width: 768px) and (max-width: 1023px) {
  .sidebar { width: 180px; }
  .main-content { padding: 16px; }
  .kanban-board, .kanban-board.has-pending { grid-template-columns: 1fr 1fr; }
  .kanban-col.done { grid-column: 1 / -1; }
  .user-tiles-grid { grid-template-columns: repeat(3, 1fr); }
}
