/* === DESIGN TOKENS === */
:root, [data-theme="light"] {
  --color-bg: #f4f3ef;
  --color-surface: #f9f8f5;
  --color-surface-2: #ffffff;
  --color-surface-offset: #eeece8;
  --color-divider: #dcd9d5;
  --color-border: #d4d1ca;
  --color-text: #28251d;
  --color-text-muted: #7a7974;
  --color-text-faint: #bab9b4;
  --color-text-inverse: #f9f8f4;
  --color-primary: #01696f;
  --color-primary-hover: #0c4e54;
  --color-primary-highlight: #cedcd8;
  --color-success: #437a22;
  --color-success-highlight: #d4dfcc;
  --color-warning: #d19900;
  --color-warning-highlight: #e9e0c6;
  --color-orange: #c55700;
  --color-orange-highlight: #e7d7c4;
  --color-error: #a13544;
  --color-error-highlight: #dececb;
  --color-blue: #006494;
  --color-blue-highlight: #c6d8e4;
  --color-shadow-sm: 0 1px 2px oklch(0.2 0.01 80 / 0.06);
  --color-shadow-md: 0 4px 12px oklch(0.2 0.01 80 / 0.08);
  --color-shadow-lg: 0 12px 32px oklch(0.2 0.01 80 / 0.12);
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;
  --sidebar-width: 240px;
  --header-height: 60px;
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --font-body: 'Inter', -apple-system, sans-serif;
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
}

[data-theme="dark"] {
  --color-bg: #171614;
  --color-surface: #1c1b19;
  --color-surface-2: #201f1d;
  --color-surface-offset: #1d1c1a;
  --color-divider: #262523;
  --color-border: #393836;
  --color-text: #cdccca;
  --color-text-muted: #797876;
  --color-text-faint: #5a5957;
  --color-text-inverse: #2b2a28;
  --color-primary: #4f98a3;
  --color-primary-hover: #227f8b;
  --color-primary-highlight: #313b3b;
  --color-success: #6daa45;
  --color-success-highlight: #3a4435;
  --color-warning: #e8af34;
  --color-warning-highlight: #4d4332;
  --color-orange: #fdab43;
  --color-orange-highlight: #564b3e;
  --color-error: #dd6974;
  --color-error-highlight: #574848;
  --color-blue: #5591c7;
  --color-blue-highlight: #3a4550;
  --color-shadow-sm: 0 1px 2px oklch(0 0 0 / 0.2);
  --color-shadow-md: 0 4px 12px oklch(0 0 0 / 0.3);
  --color-shadow-lg: 0 12px 32px oklch(0 0 0 / 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #171614;
  }
}

/* === BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }
body { font-family: var(--font-body); font-size: var(--text-sm); color: var(--color-text); background: var(--color-bg); min-height: 100dvh; line-height: 1.5; }
button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: inherit; background: none; }
* { transition: background var(--transition), color var(--transition), border-color var(--transition); }

/* === LOGIN === */
.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--color-bg);
}
.login-box {
  width: 100%;
  max-width: 480px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  box-shadow: var(--color-shadow-lg);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
  justify-content: center;
}
.login-logo-icon {
  width: 40px; height: 40px;
  background: var(--color-primary);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  color: white;
}
.login-logo h1 {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
}
.login-subtitle {
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  margin-bottom: 2rem;
}
.role-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.role-card {
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--color-surface);
}
.role-card:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-highlight);
}
.role-card.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-highlight);
}
.role-card-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-full);
  background: var(--color-surface-offset);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 0.5rem;
  color: var(--color-primary);
}
.role-card.selected .role-card-icon {
  background: var(--color-primary);
  color: white;
}
.role-card-title { font-size: var(--text-sm); font-weight: 600; }
.role-card-desc { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: 0.25rem; }

.form-field { margin-bottom: 1rem; }
.form-label { display: block; font-size: var(--text-xs); font-weight: 500; color: var(--color-text-muted); margin-bottom: 0.375rem; text-transform: uppercase; letter-spacing: 0.04em; }
.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm);
  outline: none;
}
.form-input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px oklch(from var(--color-primary, #01696f) l c h / 0.15); }
.form-textarea { resize: vertical; min-height: 100px; }

.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--color-primary);
  color: white;
}
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary {
  background: var(--color-surface-offset);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-divider); }
.btn-ghost { color: var(--color-text-muted); }
.btn-ghost:hover { color: var(--color-text); background: var(--color-surface-offset); border-radius: var(--radius-md); }
.btn-danger { background: var(--color-error); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: var(--text-xs); }

/* === APP SHELL === */
.app { display: none; min-height: 100dvh; }
.app.visible { display: flex; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}
.sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-divider);
  display: flex; align-items: center; gap: 0.75rem;
  min-height: var(--header-height);
}
.sidebar-logo-icon {
  width: 32px; height: 32px;
  background: var(--color-primary);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: white; flex-shrink: 0;
}
.sidebar-logo-text {
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: -0.01em;
}
.sidebar-logo-sub { font-size: var(--text-xs); color: var(--color-text-muted); }

.sidebar-nav { padding: 0.75rem 0.75rem; flex: 1; }
.nav-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-faint);
  padding: 0.75rem 0.5rem 0.25rem;
}
.nav-item {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: 450;
  transition: all var(--transition);
  text-decoration: none;
  margin-bottom: 0.125rem;
}
.nav-item:hover { background: var(--color-surface-offset); color: var(--color-text); }
.nav-item.active { background: var(--color-primary-highlight); color: var(--color-primary); font-weight: 600; }
.nav-item svg { flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--color-error);
  color: white;
  font-size: 0.625rem;
  font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  padding: 0 0.25rem;
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--color-divider);
}
.user-card {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.user-card:hover { background: var(--color-surface-offset); }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 600; flex-shrink: 0;
}
.user-name { font-size: var(--text-xs); font-weight: 500; }
.user-role { font-size: 0.6875rem; color: var(--color-text-muted); }

/* Main area */
.main-wrap {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100dvh;
}
.main-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
}
.main-header-title { font-size: var(--text-base); font-weight: 600; flex: 1; }
.header-actions { display: flex; align-items: center; gap: 0.5rem; }
.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-muted);
  cursor: pointer;
  position: relative;
}
.icon-btn:hover { background: var(--color-surface-offset); color: var(--color-text); }
.notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--color-error);
  border-radius: var(--radius-full);
  border: 2px solid var(--color-surface);
}

.main-content { flex: 1; padding: 1.5rem; overflow-y: auto; }

/* === CARDS === */
.card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--color-shadow-sm);
}
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi-card { padding: 1.25rem; }
.kpi-label { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.5rem; }
.kpi-value { font-size: 2rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: 0.375rem; }
.kpi-dot { width: 8px; height: 8px; border-radius: var(--radius-full); display: inline-block; margin-right: 0.375rem; }

/* === BADGES === */
.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.2rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
}
.badge-krityczny { background: var(--color-error-highlight); color: var(--color-error); }
.badge-wysoki { background: var(--color-orange-highlight); color: var(--color-orange); }
.badge-sredni { background: var(--color-warning-highlight); color: var(--color-warning); }
.badge-niski { background: var(--color-success-highlight); color: var(--color-success); }

.badge-nowe { background: var(--color-blue-highlight); color: var(--color-blue); }
.badge-wrealizacji { background: var(--color-primary-highlight); color: var(--color-primary); }
.badge-zamkniete { background: var(--color-surface-offset); color: var(--color-text-muted); }
.badge-oczekujace { background: var(--color-warning-highlight); color: var(--color-warning); }

.badge-ai { background: var(--color-primary-highlight); color: var(--color-primary); font-size: 0.625rem; }

/* === TABLE === */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--color-divider);
  cursor: pointer;
  transition: background var(--transition);
}
tbody tr:hover { background: var(--color-surface-offset); }
tbody tr:last-child { border-bottom: none; }
td { padding: 0.75rem 1rem; font-size: var(--text-sm); color: var(--color-text); vertical-align: middle; }
.td-muted { color: var(--color-text-muted); font-size: var(--text-xs); }
.td-id { font-size: var(--text-xs); color: var(--color-text-faint); font-variant-numeric: tabular-nums; }

/* === MODALS === */
.modal-overlay {
  position: fixed; inset: 0;
  background: oklch(0.15 0.01 80 / 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 560px;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: var(--color-shadow-lg);
}
.modal-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-divider);
  gap: 1rem;
}
.modal-title { font-size: var(--text-base); font-weight: 600; }
.modal-id { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: 0.125rem; }
.modal-close { color: var(--color-text-muted); flex-shrink: 0; }
.modal-close:hover { color: var(--color-text); }
.modal-body { padding: 1.25rem 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-divider);
  display: flex; align-items: center; gap: 0.75rem; justify-content: flex-end;
}

/* Info rows */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1.25rem; }
.info-item-label { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.25rem; }

/* Notes */
.notes-section { margin-top: 1.25rem; }
.notes-title { font-size: var(--text-xs); font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.75rem; }
.note-item {
  padding: 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
}
.note-meta { display: flex; justify-content: space-between; margin-bottom: 0.375rem; }
.note-author { font-size: var(--text-xs); font-weight: 600; }
.note-time { font-size: var(--text-xs); color: var(--color-text-muted); }
.note-text { font-size: var(--text-sm); }

/* Desc block */
.desc-block {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  padding: 0.875rem;
  font-size: var(--text-sm);
  color: var(--color-text);
  margin-bottom: 1.25rem;
  line-height: 1.6;
}

/* Section header */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.section-title { font-size: var(--text-base); font-weight: 600; }

/* AI Animation */
.ai-processing {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.875rem 1rem;
  background: var(--color-primary-highlight);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-primary);
  margin-top: 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ai-spinner { animation: spin 1s linear infinite; }

.ai-result {
  padding: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-primary-highlight);
  border-radius: var(--radius-md);
  margin-top: 1rem;
}
.ai-result-title { font-size: var(--text-xs); font-weight: 600; color: var(--color-primary); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.625rem; display: flex; align-items: center; gap: 0.375rem; }
.ai-result-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.375rem; }
.ai-result-label { font-size: var(--text-xs); color: var(--color-text-muted); }

/* Filters */
.filters { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filter-select {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-xs);
  cursor: pointer;
  outline: none;
}
.filter-select:focus { border-color: var(--color-primary); }

/* Success/empty states */
.success-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
}
.success-icon {
  width: 56px; height: 56px;
  background: var(--color-success-highlight);
  color: var(--color-success);
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
}
.success-title { font-size: var(--text-base); font-weight: 600; margin-bottom: 0.5rem; }
.success-desc { font-size: var(--text-sm); color: var(--color-text-muted); }

.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--color-text-muted); }
.empty-icon { margin: 0 auto 1rem; color: var(--color-text-faint); width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; }

/* Divider */
.divider { height: 1px; background: var(--color-divider); margin: 1rem 0; }

/* === RAPORTY === */
.report-controls { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
.report-controls .form-field { margin-bottom: 0; min-width: 11rem; flex: 1 1 11rem; }
.report-controls .report-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.report-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin: 1.5rem 0 1rem; }
.report-title { font-size: var(--text-lg); font-weight: 700; }
.report-meta { color: var(--color-text-muted); font-size: var(--text-sm); }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 1rem; margin-bottom: 1rem; }
.report-kpis { grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); }
.kpi-delta { font-size: var(--text-xs); font-weight: 600; margin-left: 0.375rem; }
.delta-up { color: var(--color-error); }
.delta-down { color: var(--color-success); }
.delta-none { color: var(--color-text-muted); }

/* Wykres słupkowy (poziomy) — kategorie, priorytety, problemy */
.bar-row { display: grid; grid-template-columns: minmax(6rem, 9rem) 1fr 5.5rem; align-items: center; gap: 0.625rem; font-size: var(--text-sm); margin-bottom: 0.625rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { position: relative; height: 0.75rem; background: var(--color-surface-offset); border-radius: var(--radius-full); }
.bar-fill { position: absolute; top: 0; bottom: 0; left: 0; background: var(--color-primary); border-radius: var(--radius-full); min-width: 2px; }
.bar-prev { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--color-text); opacity: 0.55; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-value small { color: var(--color-text-muted); font-size: var(--text-xs); }
.chart-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: var(--text-xs); color: var(--color-text-muted); margin-top: 0.75rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: 0.375rem; }
.legend-swatch { width: 0.75rem; height: 0.5rem; border-radius: 2px; background: var(--color-primary); }
.legend-line { width: 2px; height: 0.75rem; background: var(--color-text); opacity: 0.55; }

/* Wykres trendu (SVG) */
.trend-chart { width: 100%; height: auto; display: block; overflow: visible; }
.trend-bar { fill: var(--color-primary); }
.trend-bar:hover { fill: var(--color-primary-hover); }
.trend-grid { stroke: var(--color-divider); stroke-width: 1; }
.trend-label { fill: var(--color-text-muted); font-size: 11px; font-family: var(--font-body); }

.recommendations { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.625rem; }
.recommendations li { padding: 0.625rem 0.875rem; border-left: 3px solid var(--color-primary); background: var(--color-surface-offset); border-radius: 0 var(--radius-md) var(--radius-md) 0; font-size: var(--text-sm); line-height: 1.5; }

/* Druk / zapis do PDF — tylko treść raportu, bez nawigacji */
@media print {
  .sidebar, .main-header, .no-print, #globalError, .modal-overlay { display: none !important; }
  .main-wrap { margin-left: 0 !important; min-height: 0; }
  .main-content { padding: 0 !important; overflow: visible !important; }
  body { background: #fff !important; }
  .card { box-shadow: none !important; break-inside: avoid; }
  .report-header { margin-top: 0; }
  .bar-track, .bar-fill, .bar-prev, .trend-bar, .legend-swatch, .recommendations li, .kpi-card {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform var(--transition); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .info-grid { grid-template-columns: 1fr; }
}
/* =====================================================================
   PULPIT „NA ŻYWO", POWIADOMIENIA, ROLA MANAGERA
   ===================================================================== */

/* --- Nagłówek: wyszukiwarka, dzwonek, menu użytkownika --- */
.menu-btn { display: none; }
.header-search {
  display: flex; align-items: center; gap: 0.5rem;
  border: 1px solid var(--color-border); border-radius: var(--radius-full);
  padding: 0.3rem 0.75rem; background: var(--color-surface); min-width: 15rem;
  color: var(--color-text-muted);
}
.header-search:focus-within { border-color: var(--color-primary); color: var(--color-text); }
.header-search input { border: none; outline: none; width: 100%; font-size: var(--text-xs); }
.header-search kbd {
  font-family: inherit; font-size: 0.625rem; border: 1px solid var(--color-border);
  border-radius: 4px; padding: 0 0.3rem; color: var(--color-text-faint);
}
.icon-btn { position: relative; }
.bell-badge {
  position: absolute; top: 2px; right: 0; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: var(--radius-full); background: var(--color-error); color: #fff;
  font-size: 0.625rem; font-weight: 700; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px var(--color-surface-2);
}
.bell-badge[hidden] { display: none; }
.bell-ring { animation: dzwonek 0.9s ease-in-out; }
@keyframes dzwonek {
  0%, 100% { transform: rotate(0); } 15% { transform: rotate(14deg); } 30% { transform: rotate(-12deg); }
  45% { transform: rotate(8deg); } 60% { transform: rotate(-5deg); } 75% { transform: rotate(2deg); }
}
.dropdown {
  position: absolute; top: calc(100% + 0.5rem); right: 0; z-index: 300;
  width: min(24rem, calc(100vw - 2rem)); max-height: 70vh; overflow: auto;
  background: var(--color-surface-2); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--color-shadow-lg);
}
.dropdown[hidden] { display: none; }
.dropdown-head {
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--color-divider);
  position: sticky; top: 0; background: var(--color-surface-2);
}
.dropdown-head strong { font-size: var(--text-sm); }
.dropdown-item {
  display: flex; gap: 0.625rem; width: 100%; text-align: left; padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--color-divider); font-size: var(--text-xs);
}
.dropdown-item:hover { background: var(--color-surface-offset); }
.dropdown-item:last-child { border-bottom: none; }
.menu-wrap { position: relative; }
.user-menu .dropdown-item { align-items: center; font-size: var(--text-sm); }

/* --- Kanał aktywności --- */
.feed { list-style: none; display: flex; flex-direction: column; }
.feed-item {
  display: grid; grid-template-columns: 2rem 1fr; gap: 0.625rem; padding: 0.625rem 0.25rem;
  border-bottom: 1px solid var(--color-divider); cursor: pointer; border-radius: var(--radius-sm);
}
.feed-item:hover { background: var(--color-surface-offset); }
.feed-item:last-child { border-bottom: none; }
.feed-item.nowe .feed-text::after {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-primary); margin-left: 0.375rem; vertical-align: middle;
}
.feed-item.wjazd { animation: wjazd 0.6s ease-out; }
@keyframes wjazd {
  from { background: var(--color-primary-highlight); transform: translateY(-4px); opacity: 0.3; }
  to { background: transparent; transform: none; opacity: 1; }
}
.feed-icon {
  width: 2rem; height: 2rem; border-radius: var(--radius-full); display: flex;
  align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700;
  background: var(--color-surface-offset); color: var(--color-text-muted);
}
.feed-icon.k-status { background: var(--color-blue-highlight); color: var(--color-blue); }
.feed-icon.k-eskalacja { background: var(--color-error-highlight); color: var(--color-error); }
.feed-icon.k-komentarz { background: var(--color-primary-highlight); color: var(--color-primary); }
.feed-icon.k-ocena { background: var(--color-warning-highlight); color: var(--color-warning); }
.feed-icon.k-nowe { background: var(--color-success-highlight); color: var(--color-success); }
.feed-text { font-size: var(--text-xs); line-height: 1.45; overflow-wrap: anywhere; }
.feed-text b { font-weight: 600; }
.feed-meta { font-size: 0.6875rem; color: var(--color-text-muted); margin-top: 0.125rem; }

/* --- Toasty (powiadomienia „na żywo") --- */
.toasty { position: fixed; bottom: 1rem; right: 1rem; z-index: 9000; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
  display: flex; gap: 0.625rem; align-items: flex-start; width: min(22rem, calc(100vw - 2rem));
  background: var(--color-surface-2); border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary); border-radius: var(--radius-md);
  padding: 0.75rem 0.875rem; box-shadow: var(--color-shadow-lg); font-size: var(--text-xs);
  cursor: pointer; animation: toast-in 0.35s ease-out;
}
.toast.k-eskalacja { border-left-color: var(--color-error); }
.toast.k-sukces { border-left-color: var(--color-success); }
.toast.znika { animation: toast-out 0.3s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(1.5rem); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(1.5rem); } }

/* --- Pulpit: pasek narzędzi --- */
.pulpit-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.25rem; }
.pulpit-head h2 { font-size: var(--text-lg); font-weight: 700; letter-spacing: -0.01em; }
.pulpit-head p { color: var(--color-text-muted); font-size: var(--text-sm); }
.pulpit-tools { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.segmented { display: inline-flex; background: var(--color-surface-offset); border-radius: var(--radius-full); padding: 3px; }
.segmented button { padding: 0.3rem 0.8rem; border-radius: var(--radius-full); font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 500; }
.segmented button.on { background: var(--color-surface-2); color: var(--color-text); box-shadow: var(--color-shadow-sm); }
.live {
  display: inline-flex; align-items: center; gap: 0.4rem; font-size: var(--text-xs);
  color: var(--color-text-muted); padding: 0.3rem 0.75rem; border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-text-faint); }
.live.on .live-dot { background: var(--color-success); animation: puls 2s infinite; }
.live.on { color: var(--color-text); }
@keyframes puls {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-success) 60%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; }
}
.odswiezanie svg { transition: transform 0.6s; }
.odswiezanie.kreci svg { animation: spin 0.8s linear infinite; }

/* --- Pulpit: siatka widżetów --- */
.pulpit-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.w-12 { grid-column: span 12; } .w-8 { grid-column: span 8; } .w-6 { grid-column: span 6; } .w-4 { grid-column: span 4; }
@media (max-width: 1200px) { .w-8, .w-4 { grid-column: span 6; } }
@media (max-width: 860px) { .w-8, .w-6, .w-4 { grid-column: span 12; } }
.widget { min-width: 0; }
.widget .section-header { margin-bottom: 0.75rem; }
.widget .section-title { font-size: var(--text-sm); }
.section-sub { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 400; }
.widget-link { font-size: var(--text-xs); color: var(--color-primary); font-weight: 500; }
.widget-link:hover { text-decoration: underline; }

/* --- KPI na żywo --- */
.kpi-live { display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: 0.75rem; }
.kpi-tile {
  position: relative; padding: 1rem 1.1rem; text-align: left; overflow: hidden;
  background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  box-shadow: var(--color-shadow-sm); transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.kpi-tile[onclick] { cursor: pointer; }
.kpi-tile[onclick]:hover { transform: translateY(-2px); box-shadow: var(--color-shadow-md); border-color: var(--akcent, var(--color-primary)); }
.kpi-tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--akcent, var(--color-primary)); }
.kpi-tile .kpi-value { font-size: 1.85rem; color: var(--akcent, var(--color-text)); }
.kpi-tile .kpi-label { margin-bottom: 0.35rem; }
.kpi-tile.alarm { background: color-mix(in srgb, var(--akcent) 7%, var(--color-surface-2)); }
.kpi-tile.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--akcent, var(--color-primary)); } 100% { box-shadow: var(--color-shadow-sm); } }

/* --- Wskaźniki okresu --- */
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0.75rem; }
.metric { padding: 0.9rem 1rem; border: 1px solid var(--color-divider); border-radius: var(--radius-md); background: var(--color-surface); }
.metric-top { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.metric-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.metric-prev { font-size: 0.6875rem; color: var(--color-text-muted); margin-top: 0.25rem; }
.delta { font-size: 0.6875rem; font-weight: 700; padding: 0.1rem 0.4rem; border-radius: var(--radius-full); white-space: nowrap; }
.delta.dobrze { color: var(--color-success); background: var(--color-success-highlight); }
.delta.zle { color: var(--color-error); background: var(--color-error-highlight); }
.delta.neutralnie { color: var(--color-text-muted); background: var(--color-surface-offset); }
.sparkline { display: block; width: 100%; height: 34px; margin-top: 0.5rem; }
.spark-line { fill: none; stroke: var(--color-primary); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.spark-area { fill: var(--color-primary); opacity: 0.12; }
.spark-dot { fill: var(--color-primary); }
.stars { color: var(--color-warning); letter-spacing: 1px; font-size: 0.95rem; }
.stars .off { color: var(--color-text-faint); }

/* --- Wykres trendu (linie) --- */
.chart-wrap { position: relative; }
.lc-svg { width: 100%; height: 230px; display: block; overflow: visible; }
.lc-grid { stroke: var(--color-divider); stroke-width: 1; }
.lc-label { fill: var(--color-text-muted); font-size: 11px; font-family: var(--font-body); }
.lc-line { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.lc-area { opacity: 0.1; }
.s-przyjete { stroke: var(--color-blue); fill: var(--color-blue); }
.s-rozwiazane { stroke: var(--color-success); fill: var(--color-success); }
.lc-line.s-przyjete, .lc-line.s-rozwiazane { fill: none; }
.lc-cursor { stroke: var(--color-text-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.lc-hit { fill: transparent; cursor: crosshair; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 20; background: var(--color-text); color: var(--color-text-inverse);
  padding: 0.45rem 0.65rem; border-radius: var(--radius-md); font-size: var(--text-xs); line-height: 1.45;
  white-space: nowrap; box-shadow: var(--color-shadow-md); transform: translate(-50%, calc(-100% - 10px));
}
.tooltip[hidden] { display: none; }
.swatch { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 2px; margin-right: 0.35rem; vertical-align: middle; }
.swatch.s-przyjete { background: var(--color-blue); } .swatch.s-rozwiazane { background: var(--color-success); }

/* --- Donut --- */
.donut-wrap { display: grid; grid-template-columns: 9.5rem 1fr; gap: 1rem; align-items: center; }
@media (max-width: 420px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } }
.donut { width: 9.5rem; height: 9.5rem; }
.donut-seg { fill: none; stroke-width: 18; transition: stroke-width var(--transition), opacity var(--transition); cursor: pointer; }
.donut-seg:hover, .donut-seg.on { stroke-width: 24; }
.donut-sum { font-size: 22px; font-weight: 700; fill: var(--color-text); font-family: var(--font-body); }
.donut-cap { font-size: 10px; fill: var(--color-text-muted); font-family: var(--font-body); }
.legend-list { list-style: none; display: flex; flex-direction: column; gap: 0.35rem; font-size: var(--text-xs); min-width: 0; }
.legend-list li { display: grid; grid-template-columns: auto 1fr auto; gap: 0.5rem; align-items: center; cursor: pointer; padding: 0.15rem 0.3rem; border-radius: var(--radius-sm); }
.legend-list li:hover, .legend-list li.on { background: var(--color-surface-offset); }
.legend-list .nazwa { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-list .ile { font-variant-numeric: tabular-nums; color: var(--color-text-muted); }

/* --- Pasek statusów (lejek) --- */
.stack { display: flex; height: 0.9rem; border-radius: var(--radius-full); overflow: hidden; background: var(--color-surface-offset); margin-bottom: 0.875rem; }
.stack span { display: block; height: 100%; transition: width 0.6s ease; }
.stack-legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.5rem; }
.stack-legend button {
  display: flex; flex-direction: column; align-items: flex-start; padding: 0.5rem 0.65rem; border-radius: var(--radius-md);
  border: 1px solid var(--color-divider); text-align: left;
}
.stack-legend button:hover { border-color: var(--color-primary); }
.stack-legend b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.stack-legend small { font-size: 0.6875rem; color: var(--color-text-muted); display: flex; align-items: center; }
.k-Nowe { background: var(--color-blue); } .k-Wtrakcie { background: var(--color-primary); }
.k-Wstrzymane { background: var(--color-warning); } .k-Rozwiazane { background: var(--color-success); }
.k-Zamkniete { background: var(--color-text-faint); }

/* --- Heatmapa --- */
.heat { display: grid; grid-template-columns: 1.75rem repeat(24, minmax(0, 1fr)); gap: 2px; font-size: 0.625rem; color: var(--color-text-muted); }
.heat-cell { aspect-ratio: 1; border-radius: 3px; background: var(--color-surface-offset); min-height: 10px; }
.heat-cell.n { background: color-mix(in srgb, var(--color-primary) var(--p), var(--color-surface-offset)); }
.heat-day { display: flex; align-items: center; }
.heat-hour { text-align: center; }
.heat-legend { display: flex; align-items: center; gap: 0.35rem; justify-content: flex-end; margin-top: 0.6rem; font-size: 0.6875rem; color: var(--color-text-muted); }
.heat-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* --- SLA: odliczanie i pasek --- */
.sla { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.6875rem; font-weight: 600; font-variant-numeric: tabular-nums; padding: 0.15rem 0.5rem; border-radius: var(--radius-full); white-space: nowrap; }
.sla.w_normie { color: var(--color-success); background: var(--color-success-highlight); }
.sla.zagrozone { color: var(--color-orange); background: var(--color-orange-highlight); }
.sla.po_terminie { color: var(--color-error); background: var(--color-error-highlight); }
.sla.po_terminie::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: miganie 1.2s infinite; }
@keyframes miganie { 50% { opacity: 0.2; } }
.sla-bar { height: 4px; border-radius: var(--radius-full); background: var(--color-surface-offset); overflow: hidden; margin-top: 0.4rem; }
.sla-bar span { display: block; height: 100%; border-radius: var(--radius-full); transition: width 1s linear; }
.sla-bar .w_normie { background: var(--color-success); } .sla-bar .zagrozone { background: var(--color-orange); } .sla-bar .po_terminie { background: var(--color-error); }

/* --- Listy zadań na pulpicie --- */
.task-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.task {
  display: grid; grid-template-columns: 1fr auto; gap: 0.75rem; align-items: center; padding: 0.7rem 0.8rem;
  border: 1px solid var(--color-divider); border-radius: var(--radius-md); background: var(--color-surface);
  cursor: pointer; transition: border-color var(--transition), transform var(--transition);
}
.task:hover { border-color: var(--color-primary); }
.task.po_terminie { border-left: 3px solid var(--color-error); }
.task.zagrozone { border-left: 3px solid var(--color-orange); }
.task-title { font-weight: 500; font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; font-size: var(--text-xs); color: var(--color-text-muted); margin-top: 0.25rem; }
.task-actions { display: flex; gap: 0.35rem; align-items: center; }
.badge-esk { background: var(--color-error); color: #fff; font-size: 0.625rem; }
.badge-rola-manager { background: var(--color-blue-highlight); color: var(--color-blue); }
.badge-rola-pracownik { background: var(--color-surface-offset); color: var(--color-text-muted); }
.badge-ok { background: var(--color-success-highlight); color: var(--color-success); }
.badge-off { background: var(--color-error-highlight); color: var(--color-error); }
.badge-tmp { background: var(--color-warning-highlight); color: var(--color-warning); }

/* --- Obciążenie / rankingi --- */
.rank { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; }
.rank li { display: grid; grid-template-columns: 2rem 1fr auto; gap: 0.6rem; align-items: center; font-size: var(--text-sm); }
.avatar-sm { width: 2rem; height: 2rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.6875rem; font-weight: 700; color: #fff; background: var(--color-primary); }
.rank .bar-track { height: 0.5rem; margin-top: 0.3rem; }
.rank-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-val { font-size: var(--text-xs); color: var(--color-text-muted); text-align: right; white-space: nowrap; }
.rank-val b { color: var(--color-text); font-size: var(--text-sm); }
.bar-fill.krytyczne { background: var(--color-error); }

/* --- AI --- */
.ai-gauge { display: flex; gap: 1rem; align-items: center; }
.ring { width: 5.5rem; height: 5.5rem; flex-shrink: 0; }
.ring-bg { fill: none; stroke: var(--color-surface-offset); stroke-width: 9; }
.ring-fg { fill: none; stroke: var(--color-primary); stroke-width: 9; stroke-linecap: round; transition: stroke-dasharray 0.8s ease; }
.ring-txt { font-size: 18px; font-weight: 700; fill: var(--color-text); font-family: var(--font-body); }

/* --- Okno dialogowe (dodatkowe) --- */
.dialog-overlay { position: fixed; inset: 0; z-index: 8000; background: oklch(0.15 0.01 80 / 0.45); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.dialog { width: min(30rem, 100%); max-height: 90vh; overflow: auto; background: var(--color-surface-2); border-radius: var(--radius-xl); box-shadow: var(--color-shadow-lg); border: 1px solid var(--color-border); animation: toast-in 0.2s ease-out; }
.dialog-body { padding: 1.25rem 1.5rem; }
.dialog h3 { font-size: var(--text-base); font-weight: 600; margin-bottom: 0.35rem; }
.dialog p.muted { font-size: var(--text-sm); color: var(--color-text-muted); margin-bottom: 1rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0.9rem 1.5rem; border-top: 1px solid var(--color-divider); }
.secret {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.15rem; letter-spacing: 0.08em;
  padding: 0.75rem 1rem; border: 1px dashed var(--color-primary); border-radius: var(--radius-md); background: var(--color-primary-highlight);
}
.hint { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: 0.35rem; }
.form-error { color: var(--color-error); font-size: var(--text-xs); margin: -0.5rem 0 0.75rem; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem 1rem; }
.checks label { display: flex; gap: 0.5rem; align-items: center; font-size: var(--text-sm); cursor: pointer; }
@media (max-width: 480px) { .checks { grid-template-columns: 1fr; } }

/* Ocena gwiazdkami */
.rate { display: inline-flex; flex-direction: row-reverse; gap: 0.15rem; }
.rate input { position: absolute; opacity: 0; width: 0; height: 0; }
.rate label { font-size: 1.75rem; line-height: 1; color: var(--color-text-faint); cursor: pointer; transition: transform 0.1s; }
.rate label:hover, .rate label:hover ~ label, .rate input:checked ~ label { color: var(--color-warning); }
.rate label:hover { transform: scale(1.15); }
.rate input:focus-visible + label { outline: 2px solid var(--color-primary); border-radius: 4px; }

/* --- Zgłoszenie: rozmowa i panele akcji --- */
.thread { display: flex; flex-direction: column; gap: 0.6rem; }
.msg { max-width: 88%; padding: 0.6rem 0.8rem; border-radius: var(--radius-lg); background: var(--color-surface); border: 1px solid var(--color-divider); }
.msg.moja { align-self: flex-end; background: var(--color-primary-highlight); border-color: transparent; }
.msg.wewn { border-style: dashed; background: var(--color-warning-highlight); }
.msg-meta { display: flex; gap: 0.5rem; align-items: center; font-size: 0.6875rem; color: var(--color-text-muted); margin-bottom: 0.2rem; }
.msg-meta b { color: var(--color-text); font-weight: 600; }
.msg-text { font-size: var(--text-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.panel { border: 1px solid var(--color-divider); border-radius: var(--radius-lg); padding: 0.9rem 1rem; margin-top: 1rem; background: var(--color-surface); }
.panel.akcent { border-color: var(--color-success); background: color-mix(in srgb, var(--color-success) 6%, var(--color-surface)); }
.panel.alarm { border-color: var(--color-error); background: color-mix(in srgb, var(--color-error) 5%, var(--color-surface)); }
.panel-title { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); margin-bottom: 0.6rem; display: flex; align-items: center; gap: 0.4rem; }
.row-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--color-divider); margin: 1rem 0 0.75rem; }
.tabs button { padding: 0.5rem 0.75rem; font-size: var(--text-xs); font-weight: 600; color: var(--color-text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.timeline { list-style: none; border-left: 2px solid var(--color-divider); margin-left: 0.4rem; padding-left: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.timeline li { position: relative; font-size: var(--text-xs); }
.timeline li::before { content: ""; position: absolute; left: calc(-1rem - 6px); top: 0.3rem; width: 10px; height: 10px; border-radius: 50%; background: var(--color-surface-2); border: 2px solid var(--color-primary); }
.timeline .kiedy { color: var(--color-text-muted); }
.toggle { display: inline-flex; gap: 0; border: 1px solid var(--color-border); border-radius: var(--radius-full); overflow: hidden; }
.toggle button { padding: 0.25rem 0.7rem; font-size: var(--text-xs); color: var(--color-text-muted); }
.toggle button.on { background: var(--color-primary); color: #fff; }

/* --- Lista zgłoszeń: filtry --- */
.filters .search-input { padding: 0.375rem 0.75rem; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); font-size: var(--text-xs); min-width: 13rem; flex: 1 1 13rem; outline: none; }
.filters .search-input:focus { border-color: var(--color-primary); }
.filters label.chk { display: inline-flex; align-items: center; gap: 0.35rem; font-size: var(--text-xs); color: var(--color-text-muted); padding: 0 0.4rem; cursor: pointer; }

/* --- Zespół --- */
.team-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.person { display: flex; align-items: center; gap: 0.6rem; }
.person small { display: block; color: var(--color-text-muted); font-size: 0.6875rem; }
tr.nieaktywny td { opacity: 0.55; }
.actions-cell { display: flex; gap: 0.35rem; justify-content: flex-end; flex-wrap: wrap; }

/* Logowanie: konta demonstracyjne */
.demo-accounts { margin-top: 1.25rem; font-size: var(--text-xs); color: var(--color-text-muted); }
.demo-accounts summary { cursor: pointer; text-align: center; }
.demo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; margin-top: 0.75rem; }
.demo-grid button { padding: 0.45rem 0.6rem; border: 1px solid var(--color-border); border-radius: var(--radius-md); text-align: left; }
.demo-grid button:hover { border-color: var(--color-primary); background: var(--color-surface-offset); }
.demo-grid b { display: block; color: var(--color-text); font-size: var(--text-xs); }

/* Szkielet ładowania */
.skeleton { background: linear-gradient(90deg, var(--color-surface-offset) 25%, var(--color-divider) 37%, var(--color-surface-offset) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius-md); }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

@media (max-width: 768px) {
  .menu-btn { display: inline-flex; }
  .header-search { min-width: 0; flex: 1; }
  .header-search kbd { display: none; }
  .sidebar { z-index: 400; }
  .sidebar.open { box-shadow: var(--color-shadow-lg); }
  .main-header { gap: 0.5rem; }
  .main-header-title { display: none; }
  .pulpit-head { align-items: stretch; }
}
@media print {
  .toasty, .dialog-overlay, .dropdown { display: none !important; }
}
.nav-badge[hidden] { display: none; }
.actions-cell { flex-wrap: nowrap; }
.actions-cell .btn { white-space: nowrap; }
@media (max-width: 768px) {
  .kpi-live { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .kpi-tile { padding: 0.8rem; }
  .kpi-tile .kpi-value { font-size: 1.5rem; }
  .main-content { padding: 1rem; }
}
/* Element flex domyślnie nie kurczy się poniżej szerokości treści — szeroka
   tabela rozpychała całą stronę zamiast przewijać się w swojej karcie. */
.main-wrap, .main-content { min-width: 0; }
.akcja-konta { border: 1px solid var(--color-border); width: 32px; height: 32px; }
.akcja-konta:hover { border-color: var(--color-primary); color: var(--color-primary); }
.akcja-konta.niebezpieczny:hover { border-color: var(--color-error); color: var(--color-error); }
.td-firma { max-width: 11rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* === Pierwsze uruchomienie i zaproszenia === */
.login-screen { align-items: flex-start; padding-top: max(2rem, 6vh); }
.login-box { margin-bottom: 2rem; }
.kreator-info { font-size: var(--text-xs); color: var(--color-text); background: var(--color-primary-highlight); border-radius: var(--radius-md); padding: 0.75rem 0.9rem; margin: -1rem 0 1.25rem; line-height: 1.55; }
.kreator-info.ostrzezenie { background: var(--color-warning-highlight); margin: 0 0 0.75rem; }
.login-blad { color: var(--color-error); font-size: var(--text-sm); margin-bottom: 0.75rem; padding: 0.5rem 0.75rem; background: color-mix(in srgb, var(--color-error) 10%, transparent); border-radius: var(--radius-sm); }
.login-box code, .hint code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; background: var(--color-surface-offset); padding: 0.05rem 0.3rem; border-radius: 4px; }
.badge-rola-technik { background: var(--color-orange-highlight); color: var(--color-orange); }
.badge-rola-admin { background: var(--color-error-highlight); color: var(--color-error); }

/* === Załączniki === */
.zalaczniki { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.6rem; }
.zalaczniki li { display: flex; align-items: center; gap: 0.5rem; }
.zalaczniki li.wewn .zal-otworz { border-style: dashed; background: var(--color-warning-highlight); }
.zal-otworz { flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0.6rem; border: 1px solid var(--color-divider); border-radius: var(--radius-md); background: var(--color-surface-2); text-align: left; }
.zal-otworz:hover { border-color: var(--color-primary); }
.zal-ikona { color: var(--color-primary); display: flex; flex-shrink: 0; }
.zal-miniatura { width: 2.75rem; height: 2.75rem; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--color-divider); flex-shrink: 0; }
.zal-miniatura:not([hidden]) + .zal-ikona { display: none; }
.zal-opis { min-width: 0; display: flex; flex-direction: column; }
.zal-opis b { font-weight: 500; font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zal-opis small { font-size: 0.6875rem; color: var(--color-text-muted); }
.strefa-plikow { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 0.9rem; border: 1.5px dashed var(--color-border); border-radius: var(--radius-md); cursor: pointer; color: var(--color-text-muted); font-size: var(--text-xs); }
.strefa-plikow b { color: var(--color-primary); font-weight: 600; }
.strefa-plikow small { display: block; margin-top: 0.15rem; }
.strefa-plikow:hover, .strefa-plikow.nad { border-color: var(--color-primary); background: var(--color-primary-highlight); }
.strefa-plikow svg { flex-shrink: 0; color: var(--color-primary); }
.check { display: inline-flex; align-items: center; gap: 0.45rem; font-size: var(--text-xs); color: var(--color-text-muted); cursor: pointer; }
.pliki-chipy { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.plik-chip { display: inline-flex; align-items: center; gap: 0.35rem; max-width: 100%; padding: 0.25rem 0.3rem 0.25rem 0.6rem; border-radius: var(--radius-full); background: var(--color-surface-offset); font-size: var(--text-xs); }
.plik-chip small { color: var(--color-text-muted); }
.plik-chip button { width: 1.25rem; height: 1.25rem; border-radius: 50%; line-height: 1; color: var(--color-text-muted); }
.plik-chip button:hover { background: var(--color-error-highlight); color: var(--color-error); }
.podglad-obrazu img { display: block; max-width: 100%; max-height: 65vh; margin: 0.75rem auto 0; border-radius: var(--radius-md); border: 1px solid var(--color-divider); }
.dialog:has(.podglad-obrazu) { width: min(56rem, 100%); }
.spinacz { color: var(--color-text-muted); vertical-align: -2px; margin-left: 0.25rem; }

/* === Podobne zgłoszenia === */
.podobne { list-style: none; display: flex; flex-direction: column; gap: 0.35rem; }
.podobne li { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.5rem; border-radius: var(--radius-md); cursor: pointer; font-size: var(--text-sm); }
.podobne li:hover { background: var(--color-surface-offset); }
.podobne-tytul { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podobne-proc { flex-shrink: 0; width: 2.75rem; text-align: center; font-size: 0.6875rem; font-weight: 700; padding: 0.15rem 0; border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--color-primary-highlight) var(--p), var(--color-surface-offset) var(--p)); color: var(--color-primary); }
.podobne-ramka { margin-top: 0.75rem; padding: 0.75rem; border: 1px solid var(--color-blue-highlight); border-radius: var(--radius-md); background: color-mix(in srgb, var(--color-blue) 5%, var(--color-surface)); }

/* === Model AI === */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); gap: 1rem; }
.rozklad { margin: 0.5rem 0 0.25rem; display: flex; flex-direction: column; gap: 0.25rem; }
.rozklad-wiersz { display: grid; grid-template-columns: 8.5rem 1fr 2.5rem; gap: 0.5rem; align-items: center; font-size: var(--text-xs); }
.rozklad-wiersz small { text-align: right; color: var(--color-text-muted); }
.rozklad-pasek, .pasek-f1 { height: 0.4rem; border-radius: var(--radius-full); background: var(--color-surface-offset); overflow: hidden; display: block; }
.rozklad-pasek span, .pasek-f1 span { display: block; height: 100%; background: var(--color-primary); border-radius: inherit; }
.pasek-f1 { display: inline-block; width: 3.5rem; vertical-align: middle; margin-right: 0.35rem; }
table.macierz { font-size: var(--text-xs); }
table.macierz th, table.macierz td { padding: 0.35rem 0.4rem; text-align: center; white-space: nowrap; }
table.macierz tbody th { text-align: left; font-weight: 500; }
table.macierz td.przekatna { background: color-mix(in srgb, var(--color-success) calc(var(--a) * 55%), transparent); font-weight: 700; }
table.macierz td.pomylka { background: color-mix(in srgb, var(--color-error) calc(20% + var(--a) * 40%), transparent); }
tr.wyrozniony td { background: var(--color-primary-highlight); }
.ai-praktyka { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1rem; font-size: var(--text-sm); }
.ai-praktyka b { font-size: var(--text-base); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; }
.hint code { background: var(--color-surface-offset); padding: 0 0.25rem; border-radius: 4px; }
.powod-admina[hidden] { display: none; }

/* === SLA: zegar zatrzymany === */
.sla.wstrzymane { color: var(--color-blue); background: var(--color-blue-highlight); }

/* === Macierz ITIL w formularzu: wybór jak przyciski === */
.wybor-grupa { border: 0; padding: 0; min-width: 0; }
.wybor-grupa legend { padding: 0; }
.wybor { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.wybor label { cursor: pointer; }
.wybor input { position: absolute; opacity: 0; pointer-events: none; }
.wybor span { display: inline-block; padding: 0.4rem 0.8rem; border: 1px solid var(--color-border); border-radius: var(--radius-full); font-size: var(--text-xs); background: var(--color-surface-2); transition: var(--transition); }
.wybor label:hover span { border-color: var(--color-primary); }
.wybor input:checked + span { background: var(--color-primary); border-color: var(--color-primary); color: #fff; font-weight: 600; }
.wybor input:focus-visible + span { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* === Przełącznik (checkbox z opisem) === */
.przelacznik { display: flex; gap: 0.5rem; align-items: flex-start; font-size: var(--text-sm); margin: 0.6rem 0; cursor: pointer; line-height: 1.4; }
.przelacznik input { margin-top: 0.2rem; accent-color: var(--color-primary); }

/* === Ustawienia SLA === */
.sla-siatka { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.75rem; }
.lista-swiat { list-style: none; display: flex; flex-direction: column; gap: 0.35rem; font-size: var(--text-sm); }
.lista-swiat b { display: inline-block; min-width: 6.5rem; font-variant-numeric: tabular-nums; }

/* === Baza wiedzy === */
.kb-siatka { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.kb-karta { cursor: pointer; transition: var(--transition); }
.kb-karta:hover, .kb-karta:focus-visible { border-color: var(--color-primary); transform: translateY(-2px); box-shadow: var(--color-shadow-md); outline: none; }
.kb-karta.szkic { border-style: dashed; }
.kb-tytul { font-size: var(--text-sm); font-weight: 600; margin-bottom: 0.35rem; }
.kb-fragment { font-size: var(--text-xs); color: var(--color-text-muted); line-height: 1.5; }
.kb-statystyki { font-size: 0.6875rem; color: var(--color-text-muted); margin-top: 0.6rem; }
.kb-tresc { white-space: pre-wrap; font-size: var(--text-sm); line-height: 1.65; background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: var(--radius-md); padding: 0.9rem 1rem; }
.kb-podpowiedz { border-color: var(--color-primary-highlight); background: color-mix(in srgb, var(--color-primary) 5%, var(--color-surface)); margin: -0.25rem 0 1rem; }
.dialog.dialog-szeroki { width: min(44rem, 100%); }

/* === Szablony odpowiedzi === */
.szablon-wybor { max-width: 13rem; margin-left: auto; }
.lista-szablonow { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.lista-szablonow li { display: flex; gap: 0.75rem; justify-content: space-between; align-items: flex-start; padding: 0.6rem 0.75rem; border: 1px solid var(--color-divider); border-radius: var(--radius-md); font-size: var(--text-sm); }
.lista-szablonow small { display: block; color: var(--color-text-muted); font-size: var(--text-xs); margin-top: 0.2rem; white-space: pre-wrap; }

@media print { .kb-podpowiedz { display: none; } }
