/* ============ Tokens ============ */
:root {
  --bg: #0d1b2e;
  --surface: #142338;
  --surface-2: #1a2d45;
  --surface-3: #1f3550;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.20);
  --text: #ffffff;
  --text-muted: #c2daf0;
  --text-dim: #8aaec8;

  --accent: oklch(0.75 0.18 230);
  --accent-fg: #001830;
  --accent-soft: oklch(0.75 0.18 230 / 0.18);
  --accent-border: oklch(0.75 0.18 230 / 0.42);

  --success: oklch(0.82 0.14 155);
  --success-soft: oklch(0.82 0.14 155 / 0.18);
  --warning: oklch(0.86 0.15 75);
  --warning-soft: oklch(0.86 0.15 75 / 0.18);
  --danger: oklch(0.74 0.18 25);
  --danger-soft: oklch(0.74 0.18 25 / 0.18);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.5);

  --font-sans: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;

  --sidebar-w: 248px;
  --sidebar-w-collapsed: 68px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
html { scrollbar-gutter: stable; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* Prevent WebKit autofill background flash (blue/yellow override) */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--surface-2) inset !important;
  -webkit-text-fill-color: var(--text) !important;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ============ Layout ============ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  min-height: 100dvh;
  transition: grid-template-columns 0.2s ease;
}
.app.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

@media (max-width: 900px) {
  .app, .app.collapsed { grid-template-columns: 1fr; }
}

/* ============ Sidebar ============ */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 800;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; }
.sidebar-name-sub { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

.sidebar-nav {
  padding: 14px 10px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 14px 10px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-item .nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.app.collapsed .nav-label,
.app.collapsed .sidebar-name,
.app.collapsed .sidebar-name-sub,
.app.collapsed .nav-section-label,
.app.collapsed .sidebar-user-info { display: none; }
.app.collapsed .nav-item { justify-content: center; padding: 10px; }

.sidebar-user {
  border-top: 1px solid var(--border);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: var(--text-muted); }

/* ============ Topbar ============ */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: #0d1b2e;
  position: sticky;
  top: 0;
  z-index: 50;
}
.offline-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 24px;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  background: #b91c1c;
  position: sticky;
  top: var(--topbar-h);
  z-index: 49;
}
.status-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 5px 24px;
  background: #0e1e30;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--topbar-h);
  z-index: 49;
}
.opiekun-bar {
  padding: 6px 24px;
  font-size: 11.5px;
  color: var(--text-muted);
  background: #0e1e30;
  text-align: right;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--topbar-h);
  z-index: 49;
  letter-spacing: 0.01em;
}
.opiekun-bar a { color: var(--accent); text-decoration: none; }
.opiekun-bar a:hover { text-decoration: underline; }
.topbar-left { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.topbar-title { font-weight: 600; font-size: 16px; white-space: nowrap; }
.topbar-sub { font-size: 12px; color: var(--text-muted); }
/* Logotypy są zwykłą kolumną paska, nie elementem pozycjonowanym absolutnie.
   Dzięki temu centrują się w przestrzeni MIĘDZY tytułem a przyciskiem i nie mają
   gdzie na niego nachodzić - również po zwinięciu menu bocznego, bo kolumna
   przelicza się razem z szerokością paska. */
.topbar-center {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 0 16px;
  overflow: hidden;
}
/* Wysokości MUSZĄ być sztywne. Przy `height: auto` z `max-height` Safari na iOS
   wylicza dla logo SVG rozmiar zerowy i logo znika (PNG renderuje się normalnie).
   Sztywna wysokość daje elementowi konkretny rozmiar niezależnie od silnika. */
.topbar-logo { height: 30px; width: auto; object-fit: contain; }
.topbar-logo-meden { height: 52px; filter: brightness(0) invert(1); opacity: 0.85; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
/* Logotypy chowamy dopiero na wąskich telefonach (<=600px), żeby nie tłoczyć belki.
   Tablety i iPady (>=768px w pionie) mają je pokazywać - próg 768 błędnie je ukrywał. */
@media (max-width: 600px) {
  .topbar-center { display: none; }
}
.topbar-icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s;
}
.topbar-icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ============ Main ============ */
.main { display: flex; flex-direction: column; min-width: 0; }
.content { padding: 28px 32px; width: 100%; }
@media (min-width: 1600px) { .content { padding: 32px 48px; } }
@media (max-width: 640px) { .content { padding: 16px; } }
@media (max-width: 900px) { .content { padding: 20px; } }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.page-sub { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* ============ Cards ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}
.card-title { font-weight: 600; font-size: 15px; margin: 0; }
.card-sub { color: var(--text-muted); font-size: 12px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  transition: all 0.12s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}
.btn-primary:hover { background: oklch(0.78 0.12 195); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-danger:hover { background: oklch(0.68 0.18 25 / 0.22); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 15px; font-weight: 600; }
.btn-lg svg { width: 18px; height: 18px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }

/* ============ Inputs ============ */
.field { display: flex; flex-direction: column; gap: 6px; position: relative; }
.label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.label .req { color: var(--accent); }
.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  box-sizing: border-box;
}
/* Stała wysokość 44px — nie pozwala ikonom managera haseł (1Password, Bitwarden) rozciągać pola */
.input, .select { height: 44px; }
.textarea { min-height: 64px; }
/* iOS Safari — date/time inputs ignore padding without this */
input[type="date"],
input[type="time"],
input[type="datetime-local"] {
  -webkit-appearance: none;
  appearance: none;
  height: 44px;
  padding: 9px 12px;
  line-height: 1.4;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px oklch(0.75 0.18 195 / 0.15);
}
.input[readonly] { background: rgba(255,255,255,0.02); color: var(--text-muted); cursor: default; }
.textarea { resize: vertical; min-height: 64px; font-family: inherit; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a94a3' stroke-width='2.5'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.select option { background: var(--surface); color: var(--text); }

.input-search {
  position: relative;
}
.input-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-dim); pointer-events: none; }
.input-search input { padding-left: 36px; }

/* ============ Table ============ */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}
.table { width: 100%; border-collapse: collapse; }
.table thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}
.table tbody td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(255,255,255,0.015); }
.table .mono { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-muted); }

/* tablet/mobile table → cards */
@media (max-width: 860px) {
  .table-responsive thead { display: none; }
  .table-responsive, .table-responsive tbody, .table-responsive tr, .table-responsive td { display: block; width: 100%; }
  .table-responsive tr {
    border-bottom: 1px solid var(--border);
    padding: 12px 14px;
  }
  .table-responsive tr:last-child { border-bottom: none; }
  .table-responsive td {
    border: none;
    padding: 4px 0;
    display: flex;
    justify-content: space-between;
    gap: 12px;
  }
  .table-responsive td::before {
    content: attr(data-label);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    font-weight: 600;
  }
}

/* ============ Badges ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ============ KPI / Stat ============ */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
/* Przycisk podpowiedzi ⓘ - tapowalny na dotyku (na desktopie działa też hover przez title). */
.stat-info { background: none; border: none; padding: 2px 4px; margin-left: 3px; color: var(--text-dim); cursor: pointer; font-size: 13px; line-height: 1; vertical-align: middle; }
.stat-info:hover { color: var(--text); }
.stat-hint { position: absolute; top: 100%; left: 0; margin-top: 6px; z-index: 20; max-width: 260px; padding: 8px 10px; border-radius: 8px; background: var(--surface-3); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 12px; font-weight: 400; line-height: 1.4; white-space: normal; }
/* Dymek dosunięty do prawej krawędzi ikony - gdy ⓘ jest blisko prawego brzegu ekranu. */
.stat-hint-right { left: auto; right: 0; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 6px; }
.stat-delta { font-size: 12px; margin-top: 6px; display: inline-flex; align-items: center; gap: 4px; }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* ============ Modal ============ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.15s ease;
  /* Wymusza własną warstwę GPU — fix na Safari/iOS bleeding przez backdrop-filter */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  isolation: isolate;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}
.modal.modal-lg { max-width: 980px; }
.modal.modal-sm { max-width: 480px; }
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-weight: 600; font-size: 16px; margin: 0; }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
@media (max-width: 600px) {
  .modal-body { padding: 14px; }
  .modal-header { padding: 14px; }
  .modal-footer { padding: 12px 14px; }
  .segmented { display: flex; width: 100%; }
  .segmented button { flex: 1; text-align: center; }
}
.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
  background: var(--surface);
}

/* ============ Form Layout ============ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

.section-divider {
  margin: 22px 0 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ============ Tool entry ============ */
.tool-row {
  display: grid;
  grid-template-columns: 1fr 200px auto;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}
@media (max-width: 600px) { .tool-row { grid-template-columns: 1fr; } }

/* ============ Empty state ============ */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 32px; opacity: 0.5; margin-bottom: 8px; }

/* ============ FAB ============ */
.fab {
  display: none;
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  box-shadow: var(--shadow-lg);
  z-index: 30;
  align-items: center; justify-content: center;
}
@media (max-width: 900px) { .fab { display: flex; } }
/* Tablet w poziomie ma szerszy viewport niż 900px, więc dodatkowo pokazujemy FAB
   na wszystkich urządzeniach dotykowych - niezależnie od orientacji (tak jak w pionie). */
@media (hover: none) and (pointer: coarse) { .fab { display: flex; } }

/* Przełącznik grupowania w widoku Narzędzia */
.tools-group-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; cursor: pointer; user-select: none; }
.tools-group-toggle input { width: 16px; height: 16px; cursor: pointer; flex-shrink: 0; }

/* Przycisk rejestracji w Pulpicie - tylko na tablecie/telefonie (na desktopie jest w górnej belce). */
.dash-register-mobile { display: none; }
@media (max-width: 900px) { .dash-register-mobile { display: block; } }

.update-banner {
  position: fixed;
  left: 16px; right: 16px; bottom: 16px;
  max-width: 520px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
}
.update-banner-actions { display: flex; align-items: center; gap: 8px; }
.update-banner-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px;
}

/* ============ Tabs ============ */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab {
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ============ Drawer (mobile sidebar) ============ */
.drawer-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 80;
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-w);
    height: 100vh;
    height: 100dvh;
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .drawer-backdrop.open { display: block; }
}

/* ============ Login ============ */
.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, oklch(0.75 0.18 230 / 0.20), transparent 70%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

/* ============ Misc ============ */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.spacer { flex: 1; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.hidden { display: none !important; }

.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border-left: 3px solid var(--text-muted);
}
.alert-warning { background: var(--warning-soft); border-left-color: var(--warning); }
.alert-danger { background: var(--danger-soft); border-left-color: var(--danger); }
.alert-icon { flex-shrink: 0; margin-top: 1px; }
.alert-body { flex: 1; }
.alert-title { font-weight: 600; font-size: 13px; }
.alert-text { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.dash-split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 1100px) { .dash-split { grid-template-columns: 1fr; } }

/* progress */
.progress { width: 100%; height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.3s; }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }

/* checkbox */
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* online indicator */
.online-pill { display:inline-flex; align-items:center; gap:6px; padding:4px 10px; border-radius:999px; font-size:11.5px; font-weight:500; background:var(--success-soft); color:var(--success); border:1px solid transparent; }
.online-pill.offline { background:var(--warning-soft); color:var(--warning); }
.online-pill .dot { width:6px; height:6px; border-radius:50%; background:currentColor; }
.sync-pill { display:inline-flex; align-items:center; gap:5px; padding:4px 10px; border-radius:999px; font-size:11.5px; font-weight:500; background:var(--surface-2); color:var(--text-muted); border:1px solid var(--border); cursor:pointer; transition:background 0.15s, color 0.15s; white-space:nowrap; }
.sync-pill:hover { background:var(--surface-3); color:var(--text); }
.sync-pill.stale { background:var(--warning-soft); color:var(--warning); border-color:transparent; }
.sync-pill.stale:hover { background:oklch(0.86 0.15 75 / 0.28); }
/* Pigułka sesji - czas do automatycznego wylogowania przy braku aktywności. */
.session-pill { display:inline-flex; align-items:center; gap:5px; padding:4px 10px; border-radius:999px; font-size:11.5px; font-weight:500; background:var(--surface-2); color:var(--text-muted); border:1px solid var(--border); white-space:nowrap; }
.session-pill.warn { background:var(--warning-soft); color:var(--warning); border-color:transparent; }

/* segmented control */
.segmented { display:inline-flex; background:var(--surface-2); border:1px solid var(--border); border-radius:var(--radius-sm); padding:3px; gap:2px; flex-wrap:wrap; }
.segmented button { background:transparent; border:none; color:var(--text-muted); padding:6px 12px; border-radius:4px; font-size:13px; font-weight:500; white-space:nowrap; }
.segmented button.active { background:var(--accent); color:var(--accent-fg); }

/* Wybór typu robota: dwa osobne przyciski obok siebie (z odstępem), nie połączona kontrolka. */
.robot-toggle { display: flex; gap: 10px; width: 100%; }
.robot-toggle button { flex: 1; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted); font-size: 14px; font-weight: 500; cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.robot-toggle button:hover:not(.active) { background: var(--surface-3); color: var(--text); }
.robot-toggle button.active { background: var(--accent); color: var(--accent-fg); border-color: transparent; }

/* Multi-wybór (np. lokalizacje w Statystykach): rozwijana lista z checkboxami. */
.multiselect { position: relative; }
.multiselect-toggle { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; text-align: left; cursor: pointer; }
.multiselect-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multiselect-caret { color: var(--text-dim); flex-shrink: 0; font-size: 12px; }
.multiselect-panel { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30; max-height: 300px; overflow-y: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 4px; }
.multiselect-opt { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px; font-size: 14px; color: var(--text); cursor: pointer; }
.multiselect-opt:hover { background: var(--surface-3); }
.multiselect-opt input { flex-shrink: 0; width: 16px; height: 16px; }

/* Historia - przyciski akcji jeden pod drugim, powiększone (lepszy UX na tablecie). */
.history-actions { display: flex; flex-direction: column; align-items: stretch; gap: 8px; min-width: 150px; }
/* Waga `.table .history-actions ...` (0,3,0) celowo wyższa niż reguła BL-19 dla tabletu
   (`.table .topbar-icon-btn`, 0,2,0), żeby przyciski akcji Historii były na całą szerokość
   TAK SAMO na tablecie i na desktopie (bez tego tablet dawał kwadratowe przyciski). */
.table .history-actions .topbar-icon-btn { width: 100%; height: 40px; }
/* Przycisk „Powiadom Admina" (btn-sm) wyrównany wysokością do przycisków ikonowych (40px). */
.history-actions .btn { height: 40px; }

/* role pill */
.role-pill { font-size:11px; padding:2px 8px; border-radius:4px; font-weight:600; background:var(--surface-2); color:var(--text-muted); border:1px solid var(--border); }
.role-pill.meden { background:var(--accent-soft); color:var(--accent); border-color:transparent; }
.role-pill.admin { background:oklch(0.7 0.15 280 / 0.18); color:oklch(0.78 0.13 280); border-color:transparent; }

/* timeline (case detail) */
.detail-section { padding: 14px 0; border-bottom: 1px solid var(--border); }
.detail-section:last-child { border-bottom: none; }
.detail-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(180px, 1fr)); gap:14px; }
.detail-grid .k { font-size:11px; color:var(--text-dim); text-transform:uppercase; letter-spacing:0.06em; font-weight:600; margin-bottom:4px; }
.detail-grid .v { font-size:14px; color:var(--text); }

/* tool list item (register) */
.tool-pick {
  display:flex; align-items:center; gap:10px; padding:10px 12px; border:1px solid var(--border); border-radius:var(--radius-sm); margin-top:6px; background:var(--surface-2);
}
.tool-pick.added { border-color:var(--success); background:var(--success-soft); }

/* highlight ok flash */
@keyframes flashOk { 0% { background: var(--success-soft); } 100% { background: var(--surface-2); } }
.flash-ok { animation: flashOk 0.9s ease; }

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* Faza 4A — większe przyciski akcji w tabelach na tablecie (BL-19) */
@media (min-width: 768px) and (max-width: 1024px) {
  .table .topbar-icon-btn { width: 40px; height: 40px; }
  .table .topbar-icon-btn svg { width: 18px; height: 18px; }
}

/* Faza 6B — skalowanie kart wiadomości na tablecie (BL-24) */
@media (max-width: 1024px) {
  .messages-card-grid .detail-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .messages-card-grid .detail-grid { grid-template-columns: 1fr; }
}

