/* ===========================
   BBATS ASSET UI
   Wersja: Explorer-like sidebar + czerwone akcje + białe centrum
=========================== */

:root {
  color-scheme: light;
  --bg: #f1f1f1;
  --surface: #ffffff;
  --surface-soft: rgba(255,255,255,0.96);
  --text: #1f1f1f;
  --muted: #6b7280;
  --border: rgba(0,0,0,0.10);
  --shadow: 0 20px 45px rgba(0,0,0,0.10);
  --shadow-soft: 0 10px 28px rgba(0,0,0,0.06);
  --radius: 22px;
  --radius-sm: 14px;
  --accent: #c91014;
  --accent-soft: rgba(201,16,20,0.12);
  --danger: #c91014;
  --danger-soft: rgba(201,16,20,0.12);

  /* surface overrides referenced in dark mode */
  --surface-panel: rgba(255,255,255,0.94);
  --surface-content: rgba(255,255,255,0.82);
  --surface-login-bg: rgba(255,255,255,0.88);
  --surface-login-card: rgba(255,255,255,0.92);
  --surface-table-head: rgba(255,255,255,0.98);
  --surface-navtab: rgba(243,244,246,0.95);
  --surface-navtab-hover: rgba(247,247,247,1);
  --surface-dash-tile: #ffffff;
  --surface-dash-row: rgba(0,0,0,0.03);
  --surface-qr: rgba(245,245,245,0.7);
  --border-dash-row: rgba(0,0,0,0.06);
}

:root.dark {
  color-scheme: dark;
  --bg: #111113;
  --surface: #1c1c1f;
  --surface-soft: rgba(28,28,31,0.96);
  --text: #f0f0f0;
  --muted: #9ca3af;
  --border: rgba(255,255,255,0.10);
  --shadow: 0 20px 45px rgba(0,0,0,0.45);
  --shadow-soft: 0 10px 28px rgba(0,0,0,0.35);

  --surface-panel: rgba(28,28,31,0.96);
  --surface-content: rgba(14,14,16,0.92);
  --surface-login-bg: rgba(14,14,16,0.94);
  --surface-login-card: rgba(28,28,31,0.96);
  --surface-table-head: rgba(22,22,25,0.98);
  --surface-navtab: rgba(36,36,40,0.95);
  --surface-navtab-hover: rgba(44,44,50,1);
  --surface-dash-tile: #1c1c1f;
  --surface-dash-row: rgba(255,255,255,0.04);
  --surface-qr: rgba(28,28,31,0.85);
  --border-dash-row: rgba(255,255,255,0.06);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background:
    linear-gradient(var(--surface-login-bg), var(--surface-login-bg)),
    url('/assets/logo.png') center center / min(68vw, 900px) no-repeat fixed,
    var(--bg);
  color: var(--text);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.10), rgba(255,255,255,0.25));
  pointer-events: none;
}

img { max-width: 100%; display: block; }
.brand-logo,
.sidebar-logo { display: none; }

button, input, select, textarea { font: inherit; }

/* ====== TEXT STYLES ====== */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  color: var(--text);
}
h1 { font-size: clamp(2rem, 2.4vw, 3rem); letter-spacing: -0.04em; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.12rem; }
p { margin: 0; }
.muted { color: var(--muted); }

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ====== GLOBAL FORM ELEMENTS ====== */
button {
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}
button:active { transform: translateY(1px); }
button:focus-visible {
  outline: 3px solid rgba(201,16,20,0.18);
  outline-offset: 2px;
}

input, select, textarea {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: all 0.18s ease;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.02);
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(201,16,20,0.35);
  box-shadow: 0 0 0 4px rgba(201,16,20,0.10);
}

textarea {
  min-height: 130px;
  resize: vertical;
}

label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: .02em;
}

/* ====== BUTTONS ====== */
.btn-primary,
#btnLogin {
  background: linear-gradient(135deg, #d7181d 0%, #b60f14 100%);
  color: #fff;
  border: 1px solid #a70d12;
  box-shadow: 0 14px 28px rgba(201,16,20,0.20);
}
.btn-primary:hover,
#btnLogin:hover {
  filter: brightness(1.05);
}

.btn-light {
  background: #ffffff;
  color: var(--accent);
  border-color: rgba(201,16,20,0.20);
}
.btn-light:hover {
  background: rgba(201,16,20,0.06);
  color: #a70d12;
}

.logout {
  padding: 12px 16px;
  background: linear-gradient(135deg, #d7181d 0%, #b60f14 100%);
  border-color: #a70d12;
  color: #ffffff;
}
.logout:hover {
  filter: brightness(1.05);
}

/* ====== LOGIN ====== */
.login-wrap {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  overflow: hidden;
  background:
    linear-gradient(var(--surface-login-bg), var(--surface-login-bg)),
    url('/assets/logo.png') center center / min(72vw, 980px) no-repeat;
}

.login-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('/assets/logo.png');
  background-repeat: no-repeat;
  background-position: center center;
  background-size: clamp(420px, 72vw, 980px);
  opacity: 0.15;
  filter: none;
  pointer-events: none;
}

.login-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(255,255,255,0.10), rgba(255,255,255,0.04));
  pointer-events: none;
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  padding: 34px;
  background: var(--surface-login-card);
  border-radius: 28px;
  box-shadow: 0 26px 60px rgba(0,0,0,0.12);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  gap: 16px;
  margin-bottom: 28px;
}

.brand-logo {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: rgba(0,0,0,0.05);
  padding: 10px;
}

.brand-top {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .2em;
  color: var(--muted);
  text-transform: uppercase;
}

.brand-title {
  font-size: 2rem;
  letter-spacing: -0.04em;
}

.brand-sub {
  margin-top: 4px;
  font-size: 14px;
  color: var(--muted);
}

.form { display: grid; gap: 16px; }

.status {
  min-height: 20px;
  font-weight: 700;
  color: var(--danger);
}

.hint {
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}

/* ====== APP ====== */
.app {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

/* ====== SIDEBAR ====== */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 16px 0;
  background: linear-gradient(180deg, #4a4a4d 0%, #404043 100%);
  border-right: 1px solid rgba(255,255,255,0.08);
  box-shadow: 8px 0 26px rgba(0,0,0,0.12);
}

.sidebar-header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 10px;
  padding: 0 18px 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}

.sidebar-logo {
  width: 42px;
  height: 42px;
}

.sidebar-company {
  font-size: 11px;
  color: rgba(255,255,255,0.68);
  letter-spacing: .18em;
  text-transform: uppercase;
  font-weight: 800;
}

.sidebar-title {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.05;
  color: #ffffff;
}

.menu {
  display: block;
  margin-bottom: auto;
  padding: 4px 10px;
}

/* menu jak Explorer */
.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 10px 14px;
  margin: 0;
  border: 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  background: transparent;
  color: #f3f4f6;
  font-weight: 600;
  font-size: 14px;
  text-align: left;
  box-shadow: none;
}

.menu-item:hover {
  background: rgba(255,255,255,0.10);
  color: #ffffff;
  transform: none;
}

.menu-item.active {
  background: rgba(201,16,20,0.18);
  color: #ffffff;
  border: 1px solid rgba(201,16,20,0.34);
  box-shadow: inset 0 0 0 1px rgba(201,16,20,0.10);
}

.sidebar-footer {
  margin-top: 22px;
  padding: 14px 16px 0 16px;
  border-top: 1px solid rgba(255,255,255,0.10);
  display: grid;
  gap: 12px;
}

.whoami {
  font-size: 13px;
  color: rgba(255,255,255,0.88);
  line-height: 1.55;
}

.logout {
  width: 100%;
  border-radius: 999px;
}

/* ====== CONTENT ====== */
.content {
  padding: 32px 38px;
  display: grid;
  gap: 24px;
  background: var(--surface-content);
  backdrop-filter: blur(2px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 24px;
}

.kicker {
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
}

#pageTitle { margin-top: 6px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(201,16,20,0.10);
  border: 1px solid rgba(201,16,20,0.18);
  color: #a80d12;
  font-size: 12px;
  font-weight: 800;
}

/* ====== PANELS ====== */
.hero,
.panel,
.detail-side,
.page-header,
.filters {
  background: var(--surface-panel);
  border-radius: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.hero {
  padding: 26px;
  margin-bottom: 24px;
}

.panel {
  padding: 26px;
  margin-bottom: 24px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 28px;
  margin-bottom: 24px;
  min-height: 110px;
}

.breadcrumb { margin-bottom: 10px; }

/* ====== FILTERS ====== */
.filters {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr 1fr auto;
  gap: 14px;
  align-items: end;
}

.filters input,
.filters select,
.filters button {
  min-height: 46px;
}

.filters input,
.filters select {
  margin-bottom: 0;
}

.filters button {
  width: 100%;
}

@media (max-width: 1100px) {
  .filters {
    grid-template-columns: 1fr;
  }
  .filters button { width: 100%; }
}

/* ====== TABLE ====== */
.table-wrap { overflow: auto; }

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 18px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(0,0,0,0.08);
}

.table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-table-head);
  padding: 14px 16px;
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.table tbody td {
  padding: 16px;
  color: var(--text);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  text-align: left;
  white-space: normal;
  word-break: break-word;
}

.table tbody tr:hover {
  background: rgba(201,16,20,0.05);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table thead th + th,
.table tbody td + td {
  border-left: 1px solid rgba(0,0,0,0.08);
}

/* ====== ASSETS GROUP HEADER ROW ====== */
.table tbody tr.assets-group-header td {
  background: var(--surface-table-head);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  padding: 9px 16px;
  border-top: 3px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: default;
}

.table tbody tr.assets-group-header:first-child td {
  border-top: none;
}

.table tbody tr.assets-group-header td + td {
  border-left: none;
}

.table tbody tr.assets-group-header:hover {
  background: var(--surface-table-head);
}

:root.dark .table tbody tr.assets-group-header td {
  border-top-color: rgba(255,255,255,0.12);
  border-bottom-color: rgba(255,255,255,0.12);
}

/* ====== BADGE ====== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(201,16,20,0.10);
  color: #a80d12;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid rgba(201,16,20,0.18);
}

/* ====== DETAIL ====== */
.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) 340px;
  gap: 28px;
}

.detail-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.navtab {
  padding: 14px 18px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface-navtab);
  color: var(--text);
  font-weight: 700;
  transition: background .18s ease, transform .18s ease;
}

.navtab:hover {
  background: var(--surface-navtab-hover);
}

.navtab.active {
  background: rgba(201,16,20,0.13);
  border-color: rgba(201,16,20,0.24);
  color: #9f0d11;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.field {
  display: flex;
  flex-direction: column;
}

.field-wide {
  grid-column: 1 / -1;
}

.detail-side { padding: 22px; }

.qr-box {
  margin-top: 12px;
  min-height: 220px;
  border: 1px dashed var(--border);
  border-radius: 24px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface-qr);
}

/* ====== RESPONSIVE ====== */
@media (max-width: 1100px) {
  .app {
    grid-template-columns: 1fr;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .sidebar {
    min-height: auto;
    padding: 12px 0;
  }

  .menu {
    display: grid;
    gap: 6px;
    padding: 6px 10px;
  }

  .menu-item {
    border-bottom: 0;
  }
}

@media (max-width: 800px) {
  .content { padding: 20px; }
  .login-card { padding: 26px; }
  .page-header { padding: 20px; }
  .hero, .panel { padding: 18px; }
}

/* ===== DASHBOARD TILES ===== */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 1200px) {
  .dash-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }
}

.dash-tile {
  background: var(--surface-dash-tile);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 14px 45px rgba(0,0,0,0.06);
  min-height: 220px;
  display: flex;
  flex-direction: column;
}

.dash-tile-head {
  margin-bottom: 10px;
}

.dash-title {
  font-weight: 950;
  font-size: 16px;
}

.dash-sub {
  color: #6b7280;
  font-size: 12px;
  margin-top: 2px;
}

.dash-tile-body {
  margin-top: auto;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.dash-metric {
  min-width: 120px;
}

.dash-number {
  font-size: 44px;
  font-weight: 950;
  line-height: 1;
}

.dash-mini {
  color: #6b7280;
  font-size: 12px;
  margin-top: 6px;
}

.dash-chart {
  width: 140px;
  height: 140px;
  display: grid;
  place-items: center;
}

.dash-chart canvas {
  width: 140px !important;
  height: 140px !important;
}

.dash-list {
  display: grid;
  gap: 6px;
  width: 100%;
}

.dash-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 10px;
  background: var(--surface-dash-row);
  border: 1px solid var(--border-dash-row);
  font-size: 13px;
}

.dash-pill {
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 12px;
  background: rgba(201,16,20,0.10);
  border: 1px solid rgba(201,16,20,0.15);
  color: #c91014;
}

/* ====== Layout 3-kolumnowy TYLKO dla Asset detail i Vehicle detail ====== */
#page-assets-detail .detail-layout,
#page-vehicle-detail .detail-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

#page-assets-detail .detail-nav,
#page-vehicle-detail .detail-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  position: sticky;
  top: 24px;
  align-self: start;
}

#page-assets-detail .detail-side,
#page-vehicle-detail .detail-side {
  position: sticky;
  top: 24px;
  align-self: start;
}

/* mobile */
@media (max-width: 1100px) {
  #page-assets-detail .detail-layout,
  #page-vehicle-detail .detail-layout {
    grid-template-columns: 1fr;
  }

  #page-assets-detail .detail-nav,
  #page-vehicle-detail .detail-nav {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 6px;
  }

  #page-assets-detail .detail-side,
  #page-vehicle-detail .detail-side {
    position: static;
  }
}

/* =========================================
   GLOBAL BIG ACTION BUTTONS
========================================= */
.page-header .actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  min-width: 320px;
}

.page-header .actions button {
  min-height: 50px;
  padding: 0 22px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 14px 30px rgba(0,0,0,0.08);
}

.page-header .actions .btn-primary {
  min-width: 140px;
}

.page-header .actions .btn-light {
  min-width: 120px;
}

#btnTicketNew {
  min-width: 180px;
  min-height: 52px;
  font-size: 16px;
}

.panel,
.hero,
.page-header {
  box-shadow: 0 18px 45px rgba(0,0,0,0.06);
}

/* ===== ASSET DOCS - UPLOAD BAR ===== */
.asset-doc-upload {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 12px;
  width: 100%;
  align-items: center;
  margin-top: 12px;
}

.asset-doc-upload select {
  flex: 1;
}

.asset-doc-upload input[type="file"] {
  flex: 2;
}

.asset-doc-upload button {
  flex: 1;
}

.asset-doc-upload select,
.asset-doc-upload input[type="file"],
.asset-doc-upload button {
  height: 46px;
  border-radius: 14px;
}

.asset-doc-upload input[type="file"] {
  padding: 6px 10px;
  display: flex;
  align-items: center;
}

/* ===== ASSET DOCS LIST ===== */
.asset-doc-group {
  margin-bottom: 18px;
}

.asset-doc-group-title {
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.asset-doc-count {
  background: rgba(201,16,20,0.10);
  border: 1px solid rgba(201,16,20,0.20);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

#assetDocsList .dash-row {
  transition: all 0.15s ease;
}

#assetDocsList .dash-row:hover {
  transform: translateY(-1px);
  background: rgba(201,16,20,0.06);
}

/* ===== HARD FIX – ASSET DOCS UPLOAD ===== */
#assetDocsPanel .asset-doc-upload {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 12px;
  width: 100%;
  align-items: center;
}

#assetDocsPanel .asset-doc-upload select {
  flex: 1;
}

#assetDocsPanel .asset-doc-upload input[type="file"] {
  flex: 2;
}

#assetDocsPanel .asset-doc-upload button {
  flex: 1;
}

#assetDocsPanel .asset-doc-upload select,
#assetDocsPanel .asset-doc-upload input[type="file"],
#assetDocsPanel .asset-doc-upload button {
  height: 46px;
  border-radius: 14px;
}

#assetDocsPanel .asset-doc-upload input[type="file"] {
  padding: 6px 10px;
  display: flex;
  align-items: center;
}
/* ===== FIX: DUŻE LOGO W SIDEBAR ===== */

.sidebar-header.sidebar-header-logo {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  width: 100%;
  padding: 10px 14px 16px 14px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  overflow: hidden;
}

.sidebar-big-logo {
  display: block;
  width: 170px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

/* ważne: sidebar ma zostać sidebar, a nie rozwalić cały layout */
.sidebar {
  width: 280px;
  min-width: 280px;
  max-width: 280px;
  overflow-x: hidden;
}

.menu {
  width: 100%;
}

.menu-item {
  width: 100%;
  display: block;
}

.sidebar-footer {
  width: 100%;
}

.sidebar-footer button {
  width: 100%;
}

#assetsTable th:nth-child(2),
#assetsTable td:nth-child(2) { width: 25%; }

#assetsTable th:nth-child(3),
#assetsTable td:nth-child(3) { width: 20%; }

#assetsTable th:nth-child(4),
#assetsTable td:nth-child(4) { width: 15%; }

.page { display: none; }

/* ===== Scrollbar ===== */
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.18);
  border-radius: 999px;
}

*::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.04);
}

:root.dark *::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.16);
}

:root.dark *::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.04);
}

/* body radial overlay – tone down for dark mode */
:root.dark body::before {
  background: radial-gradient(circle at center, rgba(0,0,0,0.08), rgba(0,0,0,0.18));
}

/* ===== DARK MODE – btn-light ===== */
:root.dark .btn-light {
  background: rgba(36,36,40,1);
  color: var(--accent);
  border-color: rgba(201,16,20,0.28);
}

:root.dark .btn-light:hover {
  background: rgba(48,48,54,1);
  color: #e03035;
}

/* ===== DARK MODE – inputs/selects/textareas ===== */
:root.dark input,
:root.dark select,
:root.dark textarea {
  background: rgba(36,36,40,1);
  border-color: rgba(255,255,255,0.12);
  color: var(--text);
}

:root.dark input::placeholder,
:root.dark textarea::placeholder {
  color: rgba(156,163,175,0.7);
}

/* ===== DARK MODE – global banner ===== */
:root.dark #globalBanner {
  background: rgba(40,38,10,0.95) !important;
  border-color: rgba(200,180,0,0.25) !important;
  color: #d4b850 !important;
}

/* ===== DARK MODE – table borders ===== */
:root.dark .table {
  border-color: rgba(255,255,255,0.08);
}

:root.dark .table tbody td {
  border-bottom-color: rgba(255,255,255,0.06);
}

:root.dark .table thead th + th,
:root.dark .table tbody td + td {
  border-left-color: rgba(255,255,255,0.06);
}

/* ===== DARK MODE – QR image border ===== */
:root.dark #assetQrImg {
  border-color: rgba(255,255,255,0.12) !important;
  background: #1c1c1f !important;
}

/* =========================================
   THEME TOGGLE SWITCH
========================================= */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.theme-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-panel);
  transition: background 0.18s ease, border-color 0.18s ease;
}

.theme-switch:hover {
  border-color: rgba(201,16,20,0.30);
  color: var(--text);
}

.theme-switch input[type="checkbox"] {
  display: none;
  width: auto;
  padding: 0;
  border: none;
  background: none;
  box-shadow: none;
  color: inherit;
}

.theme-switch-track {
  width: 40px;
  height: 22px;
  background: rgba(0,0,0,0.15);
  border-radius: 999px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.22s ease;
  border: 1px solid rgba(0,0,0,0.10);
}

:root.dark .theme-switch-track {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.10);
}

.theme-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.22s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,0.22);
}

.theme-switch input:checked ~ .theme-switch-track {
  background: rgba(201,16,20,0.55);
  border-color: rgba(201,16,20,0.35);
}

.theme-switch input:checked ~ .theme-switch-track .theme-switch-thumb {
  transform: translateX(18px);
}

.theme-icon {
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
}

/* ===== TICKET MESSAGE CARDS ===== */
/* Kafelek wątku jest elementem gridu (#ticketMessagesList), a element gridu ma
   domyślnie min-width:auto — czyli nie schodzi poniżej swojej treści. Szeroka
   tabelka z maila potrafiła przez to rozepchnąć całą kolumnę i stronę. */
#ticketMessagesList { min-width: 0; }

.msg-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-navtab);
  color: var(--text);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.msg-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

/* ===================== ASYSTENT AI ===================== */
.ai-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-dash-row);
  padding: 14px 16px;
}
.ai-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ai-sub { color: var(--muted); font-size: 12px; display: block; margin-top: 2px; }
.ai-result { margin-top: 12px; }
.ai-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.ai-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.ai-badge-ok { background: rgba(16,160,80,0.14); border-color: rgba(16,160,80,0.4); }
.ai-badge-esc { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.ai-badge-cat, .ai-badge-conf { color: var(--muted); }
.ai-field { margin-top: 10px; }
.ai-label { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 4px; }
.ai-text { white-space: pre-wrap; line-height: 1.5; }
.ai-answer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.ai-note {
  background: rgba(201,16,20,0.06);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}
.ai-stats-summary { line-height: 1.7; }

/* ===================== KASA FIRMOWA ===================== */
.kasa-state {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.kasa-state .dash-number { font-size: 34px; }
.kasa-row-cancelled { opacity: .6; text-decoration: line-through; }
.kasa-row-cancelled b { text-decoration: none; }
.pill-cancelled {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent);
}
.pill-ok { font-size: 11px; color: var(--muted); }
.pill-kasa {
  font-size: 11px; padding: 1px 7px; border-radius: 999px;
  background: rgba(16,160,80,0.14); border: 1px solid rgba(16,160,80,0.4);
}

/* ===== Treść wiadomości 1:1 z maila (zachowane linie/akapity) ===== */
.msg-body { line-height: 1.5; word-break: break-word; overflow-wrap: anywhere; min-width: 0; }
.msg-body:not(.msg-body-html) { white-space: pre-wrap; }

/* Maile z Outlooka niosą własne szerokości (tabelki 800–1200 px, style inline).
   Bez tych ograniczeń rozpychały siatkę wątku — a że jest to grid, kolumna
   rosła do szerokości najszerszego maila i CAŁA strona jechała w bok, więc
   nawet zwykłe zdania przestawały się zawijać. Ramka wiadomości trzyma
   szerokość, a za szeroka treść przewija się wewnątrz siebie. */
.msg-body-html { white-space: normal; max-width: 100%; overflow-x: auto; }
.msg-body-html * { max-width: 100%; }
.msg-body-html p { margin: 0 0 10px; }
.msg-body-html div { min-height: 1px; }
.msg-body-html br { line-height: 1.5; }
.msg-body-html ul, .msg-body-html ol { margin: 6px 0 10px; padding-left: 22px; }
.msg-body-html blockquote {
  margin: 8px 0; padding: 4px 0 4px 12px;
  border-left: 3px solid var(--border, #d0d5dd); color: var(--muted, #667085);
}
.msg-body-html img { max-width: 100%; height: auto; }
.msg-body-html table { max-width: 100%; border-collapse: collapse; }
.msg-body-html td, .msg-body-html th { padding: 4px 8px; }
.msg-body-html a { text-decoration: underline; }
.msg-body-html pre { white-space: pre-wrap; }

/* ===== Oznaczenia klasyfikacji AI ===== */
.ai-tag {
  font-size: 10px; font-weight: 700; letter-spacing: .5px;
  padding: 1px 6px; border-radius: 999px; vertical-align: middle;
  background: rgba(99,102,241,0.14); border: 1px solid rgba(99,102,241,0.45);
}
.ai-summary { margin-top: 6px; }
.ai-reason { font-size: 11px; font-style: italic; margin-top: 2px; }
.ai-summary-row { font-size: 11px; color: var(--muted, #667085); margin-top: 3px; }

/* ============================== RAPORTY ============================== */
.report-controls {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end;
}
.report-controls .field { min-width: 150px; margin: 0; }
.report-check {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--muted, #667085); white-space: nowrap;
}
.report-check input { width: auto; margin: 0; }

.report-kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px;
}
.report-kpi {
  border: 1px solid var(--border, #e5e7eb); border-radius: 8px;
  padding: 10px 12px; background: rgba(127,127,127,0.04);
}
.report-kpi-label {
  font-size: 10px; letter-spacing: .6px; text-transform: uppercase;
  color: var(--muted, #667085); margin-bottom: 4px;
}
.report-kpi-value { font-size: 21px; font-weight: 700; line-height: 1.15; }
.report-kpi-sub { font-size: 11px; color: var(--muted, #667085); margin-top: 3px; min-height: 14px; }

.report-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .report-cols { grid-template-columns: 1fr; } }
.report-subtitle { font-size: 12px; margin: 12px 0 8px; opacity: .85; }
.report-chart { width: 100%; overflow-x: auto; }
.report-compare { margin-top: 14px; }
.rep-compare-table td, .rep-compare-table th { font-size: 12px; }

.rep-svg { width: 100%; height: auto; display: block; }
.rep-legend { display: flex; gap: 16px; font-size: 11px; color: var(--muted, #667085); margin-top: 6px; }
.rep-legend i, .rep-legend-row i {
  display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: middle;
}

.rep-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.rep-bar-label {
  flex: 0 0 38%; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rep-bar-track { flex: 1; height: 12px; border-radius: 3px; background: rgba(127,127,127,0.13); overflow: hidden; }
.rep-bar-fill { height: 100%; border-radius: 3px; }
.rep-bar-value { flex: 0 0 88px; text-align: right; font-size: 11px; color: var(--muted, #667085); }

.rep-donut-wrap { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.rep-donut { width: 170px; height: 170px; flex: 0 0 auto; }
.rep-donut-legend { flex: 1; min-width: 190px; }
.rep-legend-row { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-bottom: 5px; }
.rep-legend-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rep-legend-val { color: var(--muted, #667085); font-size: 11px; }

.rep-delta { font-weight: 600; }
.rep-up { color: #16a34a; }
.rep-down { color: #dc2626; }
.rep-flat { color: var(--muted, #667085); }

.rep-ai-summary { font-size: 14px; line-height: 1.6; }
.rep-ai-trend {
  margin-top: 8px; padding: 8px 12px; border-radius: 6px; font-weight: 600;
  background: rgba(124,58,237,0.10); border: 1px solid rgba(124,58,237,0.30);
}
.rep-ai-list { margin: 0; padding-left: 18px; }
.rep-ai-list li { margin-bottom: 6px; line-height: 1.5; }
.rep-ai-list li::marker { color: var(--dot, #2563eb); }
.rep-reco {
  border-left: 3px solid #f59e0b; border-radius: 0 6px 6px 0;
  background: rgba(127,127,127,0.05); padding: 9px 12px; margin-bottom: 9px;
}
.rep-reco-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.rep-reco-prio { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
.rep-reco-body { font-size: 12.5px; line-height: 1.5; margin-top: 4px; }

/* ============ POWIADOMIENIA PUSH (ntfy) ============ */
.push-subs { display: flex; flex-wrap: wrap; gap: 14px; }
.push-sub-card {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; background: var(--surface-dash-row); min-width: 220px; flex: 0 1 250px;
}
.push-sub-card h4 { margin: 0 0 6px; font-size: 13px; }
.push-sub-topic {
  font-family: ui-monospace, Consolas, monospace; font-size: 12px;
  word-break: break-all; color: var(--muted); margin-bottom: 8px;
}
.push-sub-card img {
  width: 100%; max-width: 190px; border-radius: 8px;
  background: var(--surface-qr); padding: 6px;
}
.push-events { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.push-ev {
  display: flex; align-items: flex-start; gap: 8px; font-size: 13px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px;
}
.push-ev input { margin-top: 2px; }
.push-ev span small { display: block; color: var(--muted); font-size: 11px; }
.push-state-on { color: #16a34a; font-weight: 600; }
.push-state-off { color: #dc2626; font-weight: 600; }
.push-log-ok { color: #16a34a; }
.push-log-err { color: #dc2626; }

/* ============================================================================
 * WIDOK MOBILNY
 * ----------------------------------------------------------------------------
 * Do 900px sidebar wychodzi z układu i staje się wysuwaną szufladą. Wcześniej
 * `.app` trzymał sztywne `280px + reszta`, więc na telefonie 390px zostawało
 * ~110px na treść — stąd "rozjeżdżanie się".
 *
 * Tabele: domyślnie przewijają się w bok (`.table-wrap`). Tabele oznaczone
 * `.table-cards` zamieniamy poniżej 700px na kafelki — przy sześciu kolumnach
 * przewijanie w bok jest bezużyteczne, a lista zgłoszeń to główny widok
 * otwierany z telefonu. Etykiety biorą się z `data-label` na `<td>`.
 * ==========================================================================*/

/* Elementy sterujące szufladą — na desktopie nieobecne. */
.nav-toggle,
.nav-backdrop { display: none; }

@media (max-width: 900px) {

  /* ---- szkielet ---- */
  .app { grid-template-columns: minmax(0, 1fr); }
  .content { padding: 14px 12px 48px; gap: 16px; }

  /* ---- sidebar jako szuflada ---- */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(84vw, 300px);
    z-index: 60;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.is-open { transform: none; }

  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(0, 0, 0, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
  }
  .nav-backdrop.is-open { opacity: 1; pointer-events: auto; }

  /* tło nie przewija się pod otwartą szufladą */
  body.nav-open { overflow: hidden; }

  /* ---- pasek górny: hamburger zawsze pod kciukiem ---- */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 0 -12px 4px;
    padding: 10px 12px;
    background: var(--surface-content);
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
  }

  .topbar > div:not(.topbar-right) { flex: 1 1 auto; min-width: 0; }
  .topbar h1 {
    font-size: 1.35rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-right { flex: 1 1 100%; }
  .topbar-right .pill { display: none; }   /* "#/helpdesk" — na telefonie bezużyteczne */

  /* ---- nagłówki stron: przyciski pod tytułem, na pełną szerokość ---- */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 18px 16px;
    margin-bottom: 16px;
    border-radius: 18px;
  }
  .page-header .actions { flex-wrap: wrap; justify-content: stretch; }
  .page-header .actions button {
    flex: 1 1 140px;
    min-height: 48px;
    padding: 0 16px;
  }
  .page-header .actions .btn-primary { min-width: 0; }

  /* ---- panele, formularze, filtry ---- */
  .panel { padding: 16px 14px; margin-bottom: 16px; }
  .panel,
  .detail-side,
  .filters { border-radius: 18px; }

  .detail-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .filters { grid-template-columns: minmax(0, 1fr); }

  /* iOS powiększa stronę przy focusie na polu mniejszym niż 16px */
  input, select, textarea { font-size: 16px; }
  #ticket_reply { min-height: 150px; }

  /* palec zamiast kursora */
  .menu-item { min-height: 50px; }
  .detail-nav .navtab { min-height: 44px; }

  /* Przewijanie treści maila jest już globalne (patrz .msg-body-html) —
     na telefonie dokładamy tylko luz dla tabelek o stałej szerokości. */
  .msg-body-html table { width: auto; }
}

/* 760px — ten sam próg co reszta warstwy mobilnej (pasek zakładek, typografia).
   Wcześniej było 700px, przez co w pasie 700–760 tabele były już ściśnięte,
   ale jeszcze nie kafelkowe. */
@media (max-width: 760px) {

  /* tabele nieoznaczone jako kafelkowe: przewijanie w bok zamiast ściskania */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrap > .table:not(.table-cards) { min-width: 620px; }

  /* ---- tabela jako lista kafelków ---- */
  .table-cards,
  .table-cards tbody,
  .table-cards tr,
  .table-cards td {
    display: block;
    width: 100%;
  }

  .table-cards {
    min-width: 0;
    border: 0;
    background: transparent;
    border-radius: 0;
    overflow: visible;
  }
  .table-cards thead { display: none; }

  .table-cards tr {
    margin-bottom: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow-soft);
  }

  .table-cards td {
    display: flex;
    flex-wrap: wrap;      /* wartość z kilku elementów (nazwisko + login + plakietka)
                             ma zejść do następnej linii, a nie ścisnąć się do litery */
    gap: 10px;
    align-items: baseline;
    padding: 3px 0;
    border: 0;
  }

  .table-cards td > * { min-width: 0; }

  /* Szerokości kolumn z widoku desktopowego (np. #assetsTable td:nth-child(2)
     { width: 25% }) są ustawiane selektorem z ID, więc przebijają regułę
     kafelkową i komórka zostawała wąska — tekst łamał się po jednej literze.
     Kafelek nie ma kolumn, więc kasujemy każdą narzuconą szerokość.
     !important jest tu konieczne: nie znamy z góry wszystkich selektorów
     z ID, którymi rozstawiono kolumny w widoku na komputer. */
  .table-cards td,
  .table-cards th {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  .table-cards td::before {
    content: attr(data-label);
    flex: 0 0 92px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
  }

  /* temat to treść kafelka, nie kolejny wiersz "etykieta: wartość" */
  .table-cards td[data-label="Temat"] {
    flex-direction: column;
    gap: 4px;
    padding-bottom: 8px;
    font-size: 15px;
    font-weight: 600;
  }
  .table-cards td[data-label="Temat"]::before { flex: none; }

  /* komunikat "Brak zgłoszeń" nie jest kafelkiem */
  .table-cards td[colspan] { text-align: center; padding: 10px 0; }
  .table-cards td[colspan]::before { content: none; }
}

/* ===========================================================================
 * SYNCHRONIZACJA Z MICROSOFT 365 (panel Użytkownicy)
 * ===========================================================================*/

.sync-auto {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 10px 0 16px;
  background: var(--surface-soft);
}

.sync-auto-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.sync-opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 0;
  cursor: pointer;
  line-height: 1.45;
}

/* Checkbox 20px: mniejszy jest trudny do trafienia palcem */
.sync-opt input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.sync-summary {
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 10px 0;
  background: var(--surface);
}

.sync-summary-head { font-weight: 700; margin-bottom: 10px; }

.sync-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

.sync-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 12px;
  color: var(--muted);
}

.sync-stat-num { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.1; }
.sync-stat.is-new  .sync-stat-num { color: #16a34a; }
.sync-stat.is-warn .sync-stat-num { color: #b45309; }

.sync-list { margin-top: 10px; font-size: 13px; line-height: 1.5; }
.sync-warn { color: #b45309; }

/* Konto wygaszone — widoczne na liście, ale wyraźnie „odsunięte” */
.pill-inactive {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(0,0,0,0.08);
  color: var(--muted);
}

.row-inactive td { opacity: 0.55; }
.row-inactive td:last-child { opacity: 1; }   /* przyciski muszą zostać czytelne */

/* ===========================================================================
 * TELEFON — czytelność
 * ---------------------------------------------------------------------------
 * Trzy rzeczy psuły odbiór na telefonie: (1) typografia i odstępy skalowane
 * pod monitor, (2) przyciski i pola za małe, żeby je trafić kciukiem,
 * (3) tabele ściśnięte do nieczytelnych kolumn. Poniżej po kolei.
 *
 * 44px to minimalny cel dotykowy z wytycznych Apple/Google — poniżej tego
 * użytkownik trafia obok i klika sąsiedni przycisk.
 * ===========================================================================*/

@media (max-width: 760px) {

  /* --- 1. typografia i przestrzeń --- */
  body { font-size: 15px; line-height: 1.5; }

  .content { padding: 14px 12px 80px; }        /* zapas na dole pod kciuk */
  .panel, .hero { padding: 14px; border-radius: 16px; }
  .page-header { padding: 14px; }

  h2 { font-size: 21px; line-height: 1.25; }
  h3 { font-size: 17px; }
  .breadcrumb { font-size: 11px; }

  /* Nagłówek sekcji: tytuł nad przyciskami, przyciski na całą szerokość.
     Wcześniej tytuł i 3 przyciski walczyły o jedną linijkę. */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .page-header .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .page-header .actions > button,
  .page-header .actions > a {
    flex: 1 1 calc(50% - 4px);
    min-height: 44px;
  }

  /* --- 2. cele dotykowe --- */
  button,
  .btn-light,
  .btn-primary,
  .btn-danger {
    min-height: 44px;
    font-size: 15px;
    padding: 10px 14px;
  }

  /* 16px w polach formularza to nie estetyka: przy mniejszej wartości
     iOS Safari sam przybliża stronę przy wejściu w pole i układ się rozjeżdża. */
  input, select, textarea {
    font-size: 16px;
    min-height: 44px;
  }
  .input-small { min-height: 40px; font-size: 15px; }

  .filters { gap: 10px; }
  .filters input, .filters select, .filters button { min-height: 44px; }

  /* --- 3. tabele jako kafelki (uzupełnienie reguł z sekcji wyżej) --- */
  .table-cards td::before { flex: 0 0 40%; max-width: 130px; }

  /* Wiersz akcji w kafelku: przyciski dostają całą szerokość i dzielą ją równo.
     Etykieta „AKCJE” znika — przyciski mówią same za siebie, a zabierała
     40% szerokości i spychała je do pionu. */
  .table-cards td[data-label="Akcje"],
  .table-cards td[data-label="Akcja"] {
    gap: 8px;
    padding-top: 12px;
    margin-top: 8px;
    border-top: 1px solid var(--line-soft, rgba(0,0,0,0.07)) !important;
  }
  .table-cards td[data-label="Akcje"]::before,
  .table-cards td[data-label="Akcja"]::before { content: none; }

  .table-cards td[data-label="Akcje"] button,
  .table-cards td[data-label="Akcja"] button {
    flex: 1 1 auto;
    min-width: 96px;
  }

  /* Pierwsza komórka kafelka (ID / numer) jest szumem na telefonie —
     zostaje, ale drobnym drukiem, żeby nie kradła pierwszego wiersza. */
  .table-cards td[data-label="ID"] { font-size: 12px; color: var(--muted); }

  /* --- 4. dashboard --- */
  .dash-tile {
    min-height: 0;                 /* 220px na telefonie = jeden kafelek na ekran */
    padding: 14px 16px;
  }
  .dash-grid { gap: 10px; }

  /* --- 5. raporty: wykresy i szerokie tabele nie rozpychają strony --- */
  .report-cols { grid-template-columns: 1fr; }
  canvas { max-width: 100%; height: auto !important; }
  .table-wrap { max-width: 100%; }

  /* --- 6. panel synchronizacji --- */
  .sync-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sync-auto { padding: 12px; }

  /* --- 7. menu boczne: większe pozycje, wygodniejsze zamykanie --- */
  .menu-item {
    min-height: 48px;
    font-size: 15px;
  }

  /* --- 8. jeden sposób wejścia w menu, nie dwa ---
     Hamburger u góry znika: to samo menu otwiera zakładka „Więcej” na dole,
     w zasięgu kciuka. Przycisk zostaje w drzewie, bo zakładka klika go
     programowo — ukryty element nadal odbiera .click(). */
  .nav-toggle { display: none !important; }

  /* Pasek górny bez hamburgera może oddać całą szerokość tytułowi */
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 14px;
  }

  /* 320px minimalnej szerokości na akcje rozpychało nagłówek poza ekran */
  .page-header .actions { min-width: 0; }
  .page-header .actions button { min-width: 0; box-shadow: none; }

  /* --- 9. kafelek: pigułka statusu zamiast gołego tekstu --- */
  .table-cards td .cell-pill { margin-left: auto; }

  /* Pasek powagi rysuje już ::before całego kafelka — wersja desktopowa
     (cień w pierwszej komórce) dawałaby drugą kreskę obok tytułu.
     Selektor musi mieć WYŻSZĄ wagę niż reguła desktopowa, bo tamta stoi
     niżej w pliku i przy równej wadze wygrywałaby mimo media query. */
  .table.table-cards tbody tr[data-sev] > td:first-child { box-shadow: none !important; }

  /* Wewnątrz kafelka nie ma kolumn ani wierszy tabeli, więc nie ma czego
     oddzielać. Kasujemy oba separatory z widoku tabelarycznego:
     `.table tbody td` (dolny) i `.table tbody td + td` (boczny — w kafelku
     biegł pionową kreską przez całą wysokość). Selektory muszą mieć wyższą
     wagę niż tamte, stąd `.table.table-cards`. */
  .table.table-cards tbody td,
  .table.table-cards tbody td + td {
    border: 0;
  }

  /* Nagłówek grupy w ewidencji („a.brys”) to etykieta sekcji, nie rekord */
  .table-cards tr.assets-group-header {
    margin: 18px 0 6px;
    padding: 0 2px;
    border: 0;
    background: none;
    box-shadow: none;
  }
  .table-cards tr.assets-group-header::before { content: none; }
  .table-cards tr.assets-group-header td {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: left;
    padding: 0;
    /* widok tabelaryczny daje tu tło i grube obramowanie rozdzielające grupy —
       w układzie kafelkowym rozdziela je sam odstęp */
    background: none;
    border: 0;
  }
}

/* ===========================================================================
 * PASEK ZAKŁADEK (telefon)
 * ---------------------------------------------------------------------------
 * Menu boczne wysuwane z góry kosztowało dwa dotknięcia na każde przejście
 * i było poza zasięgiem kciuka. Cztery najczęstsze cele siedzą teraz na dole.
 * Na desktopie pasek nie istnieje — tam menu boczne jest zawsze widoczne.
 * ===========================================================================*/

.tabbar { display: none; }

@media (max-width: 760px) {
  .tabbar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 24px rgba(0,0,0,0.08);
    /* zapas na pasek gestów w iPhonie */
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  /* Nadpisuje wygląd .menu-item z menu bocznego — te same przyciski,
     inny kontekst. */
  .tabbar .tab,
  .tabbar .menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    position: relative;
    min-height: 58px;
    margin: 0;
    padding: 6px 2px;
    border: 0;
    border-radius: 0;
    background: none;
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
    text-align: center;
    width: auto;
  }

  .tabbar .tab svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .tabbar .menu-item.active {
    color: var(--accent);
    background: none;
  }
  .tabbar .menu-item.active::before {
    content: "";
    position: absolute;
    top: 0;
    width: 28px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--accent);
  }

  /* Pozycja ukryta rolą (np. brak uprawnień) nie może zostawiać dziury
     w siatce czterech kolumn */
  .tabbar .menu-item.hidden { display: none; }

  .tab-badge {
    position: absolute;
    top: 6px;
    left: 50%;
    margin-left: 5px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
  }
  .tab-badge[hidden] { display: none; }

  /* Treść nie może chować się pod paskiem */
  .content { padding-bottom: 96px; }

  /* ===== Kafelek jako rekord, nie jako lista „etykieta: wartość” ===== */

  .table-cards tr {
    position: relative;
    padding-left: 18px;            /* miejsce na pasek stanu */
  }

  .table-cards tr::before {
    content: "";
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: var(--border);
  }
  .table-cards tr[data-sev="critical"]::before { background: #c91014; }
  .table-cards tr[data-sev="warning"]::before  { background: #b45309; }
  .table-cards tr[data-sev="ok"]::before        { background: #15803d; }

  /* Tytuł: bez etykiety, większy, na własnej linii */
  .table-cards td[data-card-role="title"] {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    font-size: 16px;
    font-weight: 650;
    line-height: 1.3;
    letter-spacing: -0.01em;
    padding-bottom: 6px;
  }
  .table-cards td[data-card-role="title"]::before { content: none; }

  /* Numer/identyfikator: drobny druk nad tytułem, też bez etykiety */
  .table-cards td[data-card-role="muted"] {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    padding-bottom: 0;
  }
  .table-cards td[data-card-role="muted"]::before { content: none; }
}

/* ===========================================================================
 * STAN NA PIERWSZY RZUT OKA — pigułki i pasek powagi
 * ---------------------------------------------------------------------------
 * Kolor niesie informację na obu widokach: telefon i komputer. Kolumny Status
 * i Priorytet dostają pigułkę, a cały wiersz — pasek z lewej. Skala jest
 * semantyczna i celowo różna od czerwieni marki użytej w przyciskach:
 * czerwony = wymaga reakcji teraz, bursztyn = w toku / czeka, zielony = zamknięte.
 * ===========================================================================*/

:root {
  --sev-critical: #c91014;
  --sev-critical-soft: rgba(201, 16, 20, 0.10);
  --sev-warning: #b45309;
  --sev-warning-soft: rgba(180, 83, 9, 0.12);
  --sev-ok: #15803d;
  --sev-ok-soft: rgba(21, 128, 61, 0.12);
  --sev-none: rgba(0, 0, 0, 0.06);
}

.cell-pill {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--sev-none);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: .01em;
  white-space: nowrap;
}

.cell-pill[data-tone="critical"] { background: var(--sev-critical-soft); color: var(--sev-critical); }
.cell-pill[data-tone="warning"]  { background: var(--sev-warning-soft);  color: var(--sev-warning); }
.cell-pill[data-tone="ok"]       { background: var(--sev-ok-soft);       color: var(--sev-ok); }

/* Pasek powagi na wierszu — widok na komputerze.
   Malujemy pierwszą komórkę, bo tabela ma zaokrąglone rogi z overflow:hidden
   i obramowanie na wierszu byłoby przycięte. */
.table tbody tr[data-sev] > td:first-child {
  box-shadow: inset 3px 0 0 0 var(--sev-none);
}
.table tbody tr[data-sev="critical"] > td:first-child { box-shadow: inset 3px 0 0 0 var(--sev-critical); }
.table tbody tr[data-sev="warning"]  > td:first-child { box-shadow: inset 3px 0 0 0 var(--sev-warning); }
.table tbody tr[data-sev="ok"]       > td:first-child { box-shadow: inset 3px 0 0 0 var(--sev-ok); }

/* ===========================================================================
 * INWENTARYZACJA — ekran zatwierdzania importu
 * ---------------------------------------------------------------------------
 * Układ pod czytanie z arkuszem obok: jedna osoba = jeden blok, pozycje jako
 * gęsta lista z checkboxem, stan koloru mówi od razu, co jest nowe.
 * ===========================================================================*/

.inv-legenda {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
  font-size: 13px;
}
.inv-kropka {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.inv-kropka.inv-nowe { background: var(--sev-ok, #15803d); }
.inv-kropka.inv-istnieje { background: var(--muted); }
.inv-kropka.inv-podobne { background: var(--sev-warning, #b45309); }

.inv-osoba { margin-bottom: 12px; }

.inv-osoba-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft, rgba(0,0,0,0.07));
}

.inv-osoba-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }

.inv-user {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--sev-ok-soft, rgba(21,128,61,.12));
  color: var(--sev-ok, #15803d);
  font-size: 12px;
  font-weight: 700;
}

.inv-uwaga { font-size: 12px; color: var(--muted); }
.inv-uwaga.inv-brak { color: var(--sev-warning, #b45309); font-weight: 600; }

.inv-decyzje {
  margin: 10px 0 4px;
  padding: 10px 12px;
  border-radius: 10px;
  border-left: 3px solid var(--sev-warning, #b45309);
  background: rgba(180, 83, 9, 0.07);
  font-size: 13px;
  line-height: 1.5;
}
.inv-decyzja { margin-top: 4px; }

.inv-pozycje { margin-top: 8px; }

/* Wiersz pozycji: checkbox + typ + identyfikator + model + stan */
.inv-poz {
  display: grid;
  grid-template-columns: 24px 120px minmax(120px, 1fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 4px;
  border-bottom: 1px solid var(--line-soft, rgba(0,0,0,0.05));
  cursor: pointer;
  font-size: 14px;
}
.inv-poz:hover { background: var(--surface-2, rgba(0,0,0,0.02)); }
.inv-poz input { width: 18px; height: 18px; accent-color: var(--accent); }

.inv-typ { font-weight: 650; }
.inv-id { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; }
.inv-model { color: var(--muted); font-size: 13px; }

.inv-stan {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.inv-stan.inv-nowe { background: var(--sev-ok-soft, rgba(21,128,61,.12)); color: var(--sev-ok, #15803d); }
.inv-stan.inv-istnieje { background: rgba(0,0,0,0.06); color: var(--muted); }
.inv-stan.inv-podobne { background: var(--sev-warning-soft, rgba(180,83,9,.12)); color: var(--sev-warning, #b45309); }

.inv-poz[data-stan="istnieje"] { opacity: .6; }

@media (max-width: 760px) {
  /* Na telefonie siatka pięciu kolumn nie ma sensu — składamy do dwóch linii */
  .inv-poz {
    grid-template-columns: 24px 1fr auto;
    grid-template-areas:
      "check typ stan"
      ".     id  id"
      ".     model model";
    row-gap: 2px;
  }
  .inv-poz input { grid-area: check; }
  .inv-typ { grid-area: typ; }
  .inv-id { grid-area: id; }
  .inv-model { grid-area: model; }
  .inv-stan { grid-area: stan; }
  .inv-poz .inv-uwaga { grid-column: 2 / -1; }
}

/* ===========================================================================
 * TRYB CICHY — pasek ostrzegawczy
 * ---------------------------------------------------------------------------
 * Musi być nie do przeoczenia: dopóki wisi, nikt w firmie nie dostaje maili.
 * ===========================================================================*/

.quiet-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin: 12px;
  padding: 12px 16px;
  border: 1px solid rgba(180, 83, 9, 0.4);
  border-left: 5px solid #b45309;
  border-radius: 12px;
  background: rgba(180, 83, 9, 0.10);
  color: #7c3d06;
  font-size: 14px;
  line-height: 1.45;
}
.quiet-bar[hidden] { display: none; }
.quiet-bar-text { flex: 1 1 260px; }
.quiet-bar button { flex: 0 0 auto; }

:root.dark .quiet-bar { color: #e8c79a; }

@media (max-width: 760px) {
  .quiet-bar { margin: 10px; }
  .quiet-bar button { width: 100%; }
}

/* ===========================================================================
 * PANEL POWITALNY — „co czeka na Ciebie"
 * ---------------------------------------------------------------------------
 * Otwiera się raz po zalogowaniu. Ma zastąpić krążenie po zgłoszeniach, więc
 * najważniejsza sekcja (propozycje do akceptacji) jest na górze i ma przycisk
 * wysyłki bezpośrednio w wierszu.
 * ===========================================================================*/

.briefing-btn { position: relative; }

.briefing-count {
  display: inline-block;
  min-width: 20px;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.briefing-count[hidden] { display: none; }

.briefing-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.45);
}
.briefing-backdrop[hidden] { display: none; }

.briefing {
  position: fixed;
  z-index: 95;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(860px, calc(100vw - 32px));
  max-height: min(86vh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.briefing[hidden] { display: none; }

.briefing-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.briefing-head h2 { margin: 0 0 2px; font-size: 21px; letter-spacing: -0.01em; }

.briefing-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.briefing-empty { padding: 26px 0; text-align: center; color: var(--muted); }

.briefing-section h3 {
  margin: 0 0 2px;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.briefing-badge {
  min-width: 22px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-table-head, rgba(0,0,0,0.06));
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.briefing-section-desc { font-size: 13px; margin-bottom: 10px; }

.briefing-item {
  position: relative;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 12px 14px 12px 16px;
  margin-bottom: 8px;
  border: 1px solid var(--line-soft, rgba(0,0,0,0.07));
  border-radius: 14px;
  background: var(--surface);
}

.briefing-item::before {
  content: "";
  position: absolute;
  left: 0; top: 10px; bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: transparent;
}
.briefing-item[data-sev="critical"]::before { background: var(--sev-critical, #c91014); }
.briefing-item[data-sev="warning"]::before  { background: var(--sev-warning, #b45309); }

/* Sekcja informacyjna — to już się wydarzyło, nie wymaga reakcji.
   Zielony pasek i stonowane tło odróżniają ją od rzeczy do zrobienia. */
.briefing-item-done { background: var(--surface-soft, rgba(0,0,0,0.02)); }
.briefing-item-done::before { background: var(--sev-ok, #15803d); }

.briefing-item-main { flex: 1 1 auto; min-width: 0; }

.briefing-item-no {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.briefing-conf { text-transform: none; letter-spacing: 0; }

.briefing-item-subject {
  font-size: 15px;
  font-weight: 650;
  line-height: 1.35;
  margin: 2px 0;
}

.briefing-item-meta { font-size: 13px; color: var(--muted); }

.briefing-answer {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2, rgba(0,0,0,0.04));
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 160px;
  overflow-y: auto;
}

.briefing-warn {
  margin-top: 6px;
  font-size: 13px;
  color: var(--sev-warning, #b45309);
  font-weight: 600;
}

.briefing-item-actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.briefing-item-actions button { white-space: nowrap; }

body.briefing-open { overflow: hidden; }

@media (max-width: 760px) {
  .briefing {
    top: 0; left: 0;
    transform: none;
    width: 100vw;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    border: 0;
  }
  .briefing-body { padding: 14px 14px 90px; }

  /* na telefonie akcje pod treścią, pełną szerokością */
  .briefing-item { flex-direction: column; gap: 10px; }
  .briefing-item-actions { flex-direction: row; width: 100%; }
  .briefing-item-actions button { flex: 1 1 auto; }

  /* w pasku górnym zostaje sama liczba — „Podsumowanie” nie mieści się obok tytułu */
  .briefing-btn { font-size: 0; padding: 10px 12px; }
  .briefing-count { font-size: 12px; margin-left: 0; }
}

/* ===========================================================================
 * megatarus2000 — panel asystenta w zgłoszeniu
 * ===========================================================================*/

.ai-escalation {
  margin: 10px 0 12px;
  padding: 12px 14px;
  border: 1px solid rgba(180, 83, 9, 0.35);
  border-left: 4px solid #b45309;
  border-radius: 12px;
  background: rgba(180, 83, 9, 0.08);
  color: #7c3d06;
  font-size: 14px;
  line-height: 1.5;
}

:root.dark .ai-escalation { color: #e8c79a; }

.ai-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

@media (max-width: 760px) {
  .ai-actions > button { flex: 1 1 auto; min-width: 150px; }
}

/* Szerokie treści mają przewijać się u siebie, a nie rozpychać stronę.
   `.content` jest siatką, a element siatki ma domyślnie min-width: auto —
   przez to tabela o naturalnej szerokości 620 px robiła całą stronę na 650 px
   i cały panel jechał w bok (dotyczyło Kasy, Asystenta AI i Powiadomień).
   min-width: 0 przywraca możliwość kurczenia się, dzięki czemu overflow-x
   w .table-wrap faktycznie działa. */
.content > * { min-width: 0; }
.panel, .page, .table-wrap { min-width: 0; }

/* Numery zgłoszeń, daty i kwoty mają stać w kolumnie */
.table tbody td { font-variant-numeric: tabular-nums; }

/* Numer zgłoszenia to jeden token — globalne word-break łamało „001/07/26”
   na dwie linijki, gdy kolumna wyszła wąska. */
.table tbody td[data-label="Nr"],
.table tbody td[data-label="Data"],
.table tbody td[data-card-role="muted"] { white-space: nowrap; }

/* Bardzo wąskie ekrany (iPhone SE i podobne) */
@media (max-width: 380px) {
  .page-header .actions > button,
  .page-header .actions > a { flex: 1 1 100%; }
  .sync-stats { grid-template-columns: 1fr; }
  .table-cards td::before { flex: 0 0 45%; }
}

/* ===========================================================================
   PODSUMOWANIE — pełna strona (#/briefing)
   Wykresy są czystym SVG, więc wszystkie kolory idą przez zmienne motywu:
   ta sama strona ma być czytelna w jasnym i ciemnym trybie.
   =========================================================================== */

.menu-badge {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  vertical-align: middle;
}

.brf-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

/* ---- pasek stanu asystenta ---- */
.brf-agentbar {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.5;
}
.brf-agentbar-auto   { background: rgba(47,182,124,0.10); border-color: rgba(47,182,124,0.35); }
.brf-agentbar-manual { background: var(--surface-dash-row); }

/* ---- kafelki ---- */
.brf-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.brf-tile {
  background: var(--surface-dash-tile);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow-soft);
}
.brf-tile-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.brf-tile-value { font-size: 32px; font-weight: 700; line-height: 1.15; margin: 4px 0 2px; }
.brf-tile-desc  { font-size: 12px; color: var(--muted); }
.brf-tile-alarm { border-color: rgba(226,87,76,0.55); background: rgba(226,87,76,0.08); }
.brf-tile-alarm .brf-tile-value { color: #e2574c; }
.brf-tile-warn  { border-color: rgba(224,163,62,0.5); }
.brf-tile-ok .brf-tile-value { color: #2fb67c; }

/* ---- wykresy ---- */
.brf-charts {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}
.brf-card {
  background: var(--surface-dash-tile);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  box-shadow: var(--shadow-soft);
  min-width: 0;
}
.brf-card h3 { margin: 0 0 2px; font-size: 15px; }
.brf-card-wide { grid-column: 1 / -1; }
.brf-svg { width: 100%; height: auto; margin-top: 10px; display: block; }
.brf-grid { stroke: var(--border); stroke-width: 1; }
.brf-axis { fill: var(--muted); font-size: 10px; }
.brf-axis-x { text-anchor: middle; }
.brf-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 6px; }
.brf-leg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.brf-leg i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.brf-donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 10px; }
.brf-donut { width: 150px; height: 150px; flex: 0 0 auto; }
.brf-donut-num { text-anchor: middle; font-size: 26px; font-weight: 700; fill: var(--text); }
.brf-donut-lab { text-anchor: middle; font-size: 10px; fill: var(--muted); }
.brf-donut-legend { display: grid; gap: 6px; min-width: 150px; }
.brf-leg-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; font-size: 13px; }

.brf-bars { display: grid; gap: 8px; margin-top: 10px; }
.brf-bar-row { display: grid; grid-template-columns: 105px 1fr 34px; gap: 8px; align-items: center; font-size: 12px; }
.brf-bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.brf-bar-track { background: var(--surface-dash-row); border-radius: 999px; height: 9px; overflow: hidden; }
.brf-bar-fill { background: #5b8def; height: 100%; border-radius: 999px; }
.brf-bar-val { text-align: right; font-weight: 600; }

.brf-hints {
  grid-column: 1 / -1;
  background: var(--surface-dash-row);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
}
.brf-hints h3 { margin: 0 0 8px; font-size: 15px; }
.brf-hints ul { margin: 0; padding-left: 18px; display: grid; gap: 7px; }
.brf-hints li { font-size: 13px; line-height: 1.55; }

/* ---- sekcje z listami ---- */
.brf-section { margin-bottom: 24px; }
.brf-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brf-section-head h3 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.brf-count {
  background: var(--surface-dash-row);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 12px;
  font-weight: 700;
}
.brf-section-alarm .brf-count { background: rgba(226,87,76,0.15); border-color: rgba(226,87,76,0.4); color: #e2574c; }
.brf-section-desc { font-size: 13px; margin: 2px 0 10px; }
.brf-list { display: grid; gap: 10px; }

.brf-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
  background: var(--surface-dash-tile);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: opacity .18s ease;
}
.brf-item-body { min-width: 0; flex: 1; }
.brf-item-actions { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
.brf-item-actions button { white-space: nowrap; }
.brf-item-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; }
.brf-no { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted); }
.brf-chip { font-size: 11px; border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; color: var(--muted); }
.brf-chip-seen { background: var(--surface-dash-row); }
.brf-subject { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.brf-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.brf-reason { font-size: 13px; margin-top: 6px; }
.brf-quote {
  margin: 6px 0 0;
  padding: 6px 10px;
  border-left: 3px solid var(--border);
  background: var(--surface-dash-row);
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.brf-answer {
  margin-top: 7px;
  padding: 8px 10px;
  background: var(--surface-dash-row);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.brf-conf { font-size: 12px; color: var(--muted); margin-top: 4px; }
.brf-tonwarn {
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(224,163,62,0.14);
  border: 1px solid rgba(224,163,62,0.4);
  font-size: 12px;
}
.brf-crit { border-left-color: #e2574c; }
.brf-warn { border-left-color: #e0a33e; }
.brf-seen { opacity: .55; }
.brf-fading { opacity: .25; pointer-events: none; }

.brf-empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.brf-empty-ico { font-size: 42px; }
.brf-empty h3 { margin: 8px 0 4px; color: var(--text); }

/* ---- zgłoszenie oddane człowiekowi: cały wiersz na liście ---- */
tr.row-escalated > td {
  background: rgba(226,87,76,0.10);
  border-top: 1px solid rgba(226,87,76,0.30);
  border-bottom: 1px solid rgba(226,87,76,0.30);
}
tr.row-escalated:hover > td { background: rgba(226,87,76,0.18); }
tr.row-escalated > td:first-child { box-shadow: inset 4px 0 0 #e2574c; }
.esc-flag { font-size: 11px; font-weight: 700; color: #e2574c; white-space: nowrap; }
.esc-reason { font-size: 11px; color: #e2574c; opacity: .85; margin-top: 2px; }

@media (max-width: 900px) {
  .brf-charts { grid-template-columns: 1fr; }
  .brf-item { flex-direction: column; }
  .brf-item-actions { flex-direction: row; flex-wrap: wrap; width: 100%; }
}
