/* Kompaktowa sekcja filtrów na index.php */
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}
.filters label {
  font-size: 13px;
  margin-bottom: 4px;
  display: block;
}
.filters input,
.filters select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  font-size: 14px;
}
.filters .btn {
  padding: 11px 14px;
}
.filters .btn.ghost {
  padding: 11px 14px;
}

/* Spójniejsze pola tekstowe/textarea */
.sec textarea,
.sec input[type="text"],
.sec input[type="email"],
.sec input[type="date"],
.sec select {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
}
.sec textarea {
  min-height: 110px;
  resize: vertical;
}
.three-textareas {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 14px;
}
/* Rozciągnij pola tekstowe do pełnej szerokości kolumny */
.three-textareas textarea {
  width: 100%;
  box-sizing: border-box;
}
@media (min-width: 1200px) {
  .three-textareas {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Uładnij input pliku */
.file-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}
.file-input::-webkit-file-upload-button {
  background: #2563eb;
  color: #fff;
  border: 1px solid #1d4ed8;
  border-radius: 6px;
  padding: 8px 14px;
  margin-right: 10px;
  cursor: pointer;
  font-weight: 600;
}
.file-input::file-selector-button {
  background: #2563eb;
  color: #fff;
  border: 1px solid #1d4ed8;
  border-radius: 6px;
  padding: 8px 14px;
  margin-right: 10px;
  cursor: pointer;
  font-weight: 600;
}
.file-input::-webkit-file-upload-button:hover,
.file-input::file-selector-button:hover {
  background: #1d4ed8;
}

.attachments-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.attachment-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}
.attachment-name a {
  color: #1d4ed8;
  text-decoration: none;
  word-break: break-all;
}
.attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.attachment-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.attachment-thumb {
  display: block;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  aspect-ratio: 4 / 3;
  position: relative;
  overflow: hidden;
}
.attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.attachment-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #6b7280;
  background: #f1f5f9;
}
.attachment-meta {
  padding: 8px 10px;
  display: grid;
  gap: 8px;
}
.attachment-meta .attachment-name {
  font-size: 12px;
  color: #0f172a;
  text-decoration: none;
  word-break: break-all;
}
.inline-form {
  margin: 0;
}
.btn.small {
  padding: 6px 10px;
  font-size: 13px;
}
.last-mod-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.last-mod-row input[readonly] {
  flex: 1;
}

/* Karty i etykiety w formularzach (new/view) */
.card h2, .card h3, .card h4 {
  margin-top: 0;
  margin-bottom: 12px;
}
.card label {
  display: inline-block;
  margin-bottom: 4px;
  font-weight: 600;
  color: #111827;
}

.notify-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  user-select: none;
  min-height: 36px;
  height: 36px;
  font-size: 14px;
  font-weight: 600;
  color: #0f62fe;
}
.notify-box input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #0f62fe;
}

.multi-select {
  position: relative;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  width: 100%;
  min-width: 220px;
}
.multi-select summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #111827;
  font-weight: 500;
  min-height: 42px;
}
.multi-select summary .selected-status {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 12px;
}
.multi-select summary::-webkit-details-marker {
  display: none;
}
.multi-select summary::after {
  content: '▾';
  font-size: 12px;
  color: #6b7280;
}
.multi-select[open] summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: 1px solid #e5e7eb;
}
.multi-options {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - 1px);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid #e5e7eb;
  border-top: none;
  background: #f9fafb;
  max-height: 220px;
  overflow-y: auto;
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
  z-index: 20;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
}
.multi-select {
  position: relative;
}
.multi-select:not([open]) .multi-options {
  display: none;
}
.multi-options label {
  font-weight: 400;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px 0;
}
.multi-options label span {
  display: inline-block;
}
.multi-options input[type="checkbox"] {
  accent-color: #2563eb;
}

.pill-link {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: #0f172a;
  text-decoration: none;
  margin-right: 6px;
  margin-bottom: 6px;
  transition: all .15s ease;
  font-size: 14px;
}
.pill-link:hover {
  border-color: #2563eb;
  color: #2563eb;
  box-shadow: 0 1px 3px rgba(37,99,235,0.2);
}
.status-filter {
  grid-column: span 2;
  min-width: 320px;
}
@media (max-width: 900px) {
  .status-filter {
    grid-column: span 1;
    min-width: auto;
  }
}
/* Logo w nagłówku */
.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}
.brand-logo {
  height: 28px;
  width: auto;
  display: block;
}

/* Uproszczona tabela reklamacji na mobile */
.tablewrap .clickable-row {
  cursor: pointer;
}

/* Lista reklamacji: kolumny techniczne bez zawijania, opisowe z zawijaniem. */
.tablewrap .complaints-table {
  width: 100%;
  table-layout: auto;
}
.tablewrap .complaints-table .col-id,
.tablewrap .complaints-table .col-case,
.tablewrap .complaints-table .col-received,
.tablewrap .complaints-table .col-closed,
.tablewrap .complaints-table .col-phone,
.tablewrap .complaints-table .col-brand {
  white-space: nowrap !important;
}
.tablewrap .complaints-table .col-id { width: 56px; }
.tablewrap .complaints-table .col-case { width: 160px; }
.tablewrap .complaints-table .col-received { width: 100px; }
.tablewrap .complaints-table .col-closed { width: 110px; }
.tablewrap .complaints-table .col-phone { width: 140px; }
.tablewrap .complaints-table .col-brand { width: 95px; }

.tablewrap .complaints-table .col-status,
.tablewrap .complaints-table .col-customer,
.tablewrap .complaints-table .col-model {
  white-space: normal;
}

.tablewrap .complaints-table .col-status { width: 210px; }
.tablewrap .complaints-table .col-customer { width: 260px; }
.tablewrap .complaints-table .col-model {
  min-width: 180px;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
}

.tablewrap .complaints-table .col-status .badge {
  display: inline-block;
  max-width: 100%;
  line-height: 1.25;
  white-space: normal;
}

/* Laptop: ukryj mniej istotne kolumny, aby uniknac poziomego scrolla. */
@media (max-width: 1280px) {
  .tablewrap .complaints-table .col-phone,
  .tablewrap .complaints-table .col-brand {
    display: none;
  }
  .tablewrap .complaints-table .col-customer { width: 240px; }
  .tablewrap .complaints-table .col-model { min-width: 220px; }
}

/* Tablet: skupienie na najwazniejszych danych. */
@media (max-width: 1024px) {
  .tablewrap .complaints-table .col-id,
  .tablewrap .complaints-table .col-received,
  .tablewrap .complaints-table .col-closed {
    display: none;
  }
  .tablewrap .complaints-table .col-case { width: 150px; }
  .tablewrap .complaints-table .col-status { width: 190px; }
  .tablewrap .complaints-table .col-customer { width: 220px; }
  .tablewrap .complaints-table .col-model { min-width: 210px; }
}

@media (max-width: 720px) {
  .tablewrap .complaints-table .col-id,
  .tablewrap .complaints-table .col-received,
  .tablewrap .complaints-table .col-closed,
  .tablewrap .complaints-table .col-phone,
  .tablewrap .complaints-table .col-brand,
  .tablewrap .complaints-table .col-actions {
    display: none;
  }
  .tablewrap .complaints-table th,
  .tablewrap .complaints-table td {
    padding: 8px 10px;
  }
  .tablewrap .complaints-table .col-case { width: 130px; }
  .tablewrap .complaints-table .col-status { width: 170px; }
  .tablewrap .complaints-table .col-customer { width: 180px; }
  .tablewrap .complaints-table .col-model { min-width: 150px; }
}

/* View drawer: inne reklamacje */
.view-layout {
  position: relative;
}

/* Mapa EAN - przyciski akcji w jednym rzędzie */
.ean-actions-cell {
  min-width: 340px;
}
.ean-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow-x: auto;
}
.ean-actions-row .btn {
  flex: 0 0 auto;
}
.view-main {
  min-width: 0;
  max-width: 1100px;
  margin: 0 auto;
}
.content-wide {
  max-width: 1600px;
}
.related-drawer {
  position: fixed;
  right: 0;
  top: 84px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
  padding-right: 0;
}
.related-toggle {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid #0f172a;
  border-right: 0;
  border-radius: 999px 0 0 999px;
  background: #0f172a;
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.24);
  transform: translateX(14px);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.related-toggle:hover {
  transform: translateX(0);
  background: #111827;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.28);
}
.related-toggle__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f97316;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.related-panel {
  position: absolute;
  right: 0;
  top: calc(100% - 2px);
  width: 360px;
  max-width: min(92vw, 420px);
  max-height: calc(100vh - 160px);
  transform: translateX(110%);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transition: transform 0.24s ease, opacity 0.24s ease;
}
.related-panel .card {
  max-height: 100%;
  overflow: auto;
  margin: 0;
}
.related-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.related-panel__head h3 {
  margin: 0;
}
.related-close {
  border: 0;
  background: #e2e8f0;
  color: #0f172a;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
}
.related-close:hover {
  background: #cbd5f5;
}
.related-backdrop {
  position: fixed;
  inset: 0;
  border: 0;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 0;
}
.related-drawer.is-open .related-panel {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}
.related-drawer.is-open .related-backdrop {
  opacity: 1;
  pointer-events: auto;
}
.related-drawer.is-hover .related-panel {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}
.related-drawer.is-open .related-toggle,
.related-drawer.is-hover .related-toggle {
  transform: translateX(0);
  background: #111827;
}
@media (max-width: 720px) {
  .related-drawer {
    top: 72px;
    padding-right: 0;
  }
  .related-toggle {
    padding: 8px 12px;
    font-size: 12px;
    transform: translateX(8px);
  }
  .related-panel {
    max-height: calc(100vh - 140px);
  }
}
.related-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.related-item {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fafc;
}
.related-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.related-link {
  font-weight: 600;
  color: #0f172a;
  text-decoration: none;
}
.related-link:hover {
  text-decoration: underline;
}
.related-date {
  font-size: 12px;
  color: #6b7280;
}
.related-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  font-size: 12px;
  color: #6b7280;
}
.related-status-text {
  font-weight: 600;
  color: #111827;
}

html[data-theme="dark"] .filters input,
html[data-theme="dark"] .filters select,
html[data-theme="dark"] .sec textarea,
html[data-theme="dark"] .sec input[type="text"],
html[data-theme="dark"] .sec input[type="email"],
html[data-theme="dark"] .sec input[type="date"],
html[data-theme="dark"] .sec select,
html[data-theme="dark"] .file-input {
  background: #111827;
  color: #e5e7eb;
  border-color: #374151;
}
html[data-theme="dark"] select option {
  background: #111827;
  color: #e5e7eb;
}
html[data-theme="dark"] .card label {
  color: #e5e7eb;
}
html[data-theme="dark"] .notify-box,
html[data-theme="dark"] .multi-select,
html[data-theme="dark"] .multi-options,
html[data-theme="dark"] .pill-link {
  background: #0f172a;
  color: #e5e7eb;
  border-color: #334155;
}
html[data-theme="dark"] .multi-select summary,
html[data-theme="dark"] .multi-select summary .selected-status,
html[data-theme="dark"] .multi-options label,
html[data-theme="dark"] .multi-options label span {
  color: #e5e7eb;
}
html[data-theme="dark"] .multi-select summary::after {
  color: #93c5fd;
}
html[data-theme="dark"] .attachment-card,
html[data-theme="dark"] .attachment-thumb,
html[data-theme="dark"] .attachment-placeholder,
html[data-theme="dark"] .related-item {
  background: #111827;
  border-color: #1f2937;
}
html[data-theme="dark"] .attachment-meta .attachment-name,
html[data-theme="dark"] .related-link,
html[data-theme="dark"] .related-status-text {
  color: #e5e7eb;
}
html[data-theme="dark"] .related-toggle {
  background: #111827;
  border-color: #334155;
}
html[data-theme="dark"] .related-close {
  background: #1f2937;
  color: #e5e7eb;
}

html[data-theme="dark"] #attachment_dropzone,
html[data-theme="dark"] #attachments_dropzone_new,
html[data-theme="dark"] #attachments_dropzone_public {
  background: #111827 !important;
  border-color: #334155 !important;
  color: #e5e7eb !important;
}
html[data-theme="dark"] #attachment_hint,
html[data-theme="dark"] #attachment_list,
html[data-theme="dark"] #attachments_list_new,
html[data-theme="dark"] #attachments_list_public,
html[data-theme="dark"] #attachment_dropzone .small,
html[data-theme="dark"] #attachments_dropzone_new .small,
html[data-theme="dark"] #attachments_dropzone_public .small {
  color: #cbd5e1 !important;
}

.login-info-box {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
}
html[data-theme="dark"] .login-info-box {
  background: #111827;
  border-color: #334155;
  color: #e5e7eb;
}
html[data-theme="dark"] .login-info-box p {
  color: #cbd5e1;
}
