@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --app-font: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --app-bg: #f3f4f6;
  --app-surface: #ffffff;
  --app-border: #e5e7eb;
  --app-text: #111827;
  --app-muted: #6b7280;
  --app-primary: #2563eb;
  --app-primary-soft: #eff6ff;
  --app-success: #16a34a;
  --app-warning: #d97706;
  --app-danger: #dc2626;
}

html {
  scrollbar-gutter: stable;
  background: var(--app-bg);
  font-family: var(--app-font);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--app-bg);
  color: var(--app-text);
  font-family: var(--app-font);
  font-synthesis: none;
  font-variant-ligatures: contextual common-ligatures;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea,
optgroup {
  font: inherit;
}

h1,
h2,
h3,
h4,
h5,
h6,
.app-title,
.app-section-title,
.panel-section-title {
  letter-spacing: -0.025em;
}

[x-cloak] {
  display: none !important;
}

.app-shell {
  width: 100%;
  max-width: 1536px;
  margin: 0 auto;
  padding: 1.5rem;
}

.app-stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.app-card {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 1rem;
  box-shadow: 0 5px 18px rgba(15, 23, 42, 0.06);
}

.app-card-hover {
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.app-card-hover:hover {
  transform: translateY(-1px);
  border-color: #bfdbfe;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.10);
}

.app-page-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 1rem;
  box-shadow: 0 5px 18px rgba(15, 23, 42, 0.06);
}

.app-heading-icon {
  width: 2.75rem;
  height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.9rem;
  color: #1d4ed8;
  background: #eff6ff;
  flex: 0 0 auto;
}

.app-kicker {
  margin: 0;
  color: #3b82f6;
  font-size: 0.72rem;
  line-height: 1rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.app-title {
  margin: 0.2rem 0 0;
  color: #111827;
  font-size: clamp(1.5rem, 3vw, 2rem);
  line-height: 1.2;
  font-weight: 800;
}

.app-subtitle {
  margin: 0.4rem 0 0;
  color: var(--app-muted);
  font-size: 0.9rem;
}

.app-stat-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 1rem;
}

@media (min-width: 640px) {
  .app-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .app-stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.app-stat {
  padding: 1.15rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 1rem;
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.045);
}

.app-stat-label {
  color: #9ca3af;
  font-size: 0.7rem;
  line-height: 1rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-stat-value {
  margin-top: 0.4rem;
  color: #111827;
  font-size: 1.65rem;
  line-height: 2rem;
  font-weight: 800;
}

.app-field-label {
  display: block;
  margin-bottom: 0.4rem;
  color: #374151;
  font-size: 0.875rem;
  font-weight: 700;
}

.app-input,
.app-select,
.app-textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #d1d5db;
  border-radius: 0.75rem;
  background: #fff;
  color: #111827;
  padding: 0.72rem 0.85rem;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.app-textarea {
  min-height: 7rem;
  resize: vertical;
}

.app-input:focus,
.app-select:focus,
.app-textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}

.app-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.75rem;
  padding: 0.65rem 1rem;
  border: 1px solid transparent;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.app-btn:hover {
  transform: translateY(-1px);
}

.app-btn-primary {
  color: #fff;
  background: #2563eb;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.app-btn-primary:hover { background: #1d4ed8; }
.app-btn-success { color: #fff; background: #16a34a; }
.app-btn-success:hover { background: #15803d; }
.app-btn-danger { color: #fff; background: #dc2626; }
.app-btn-danger:hover { background: #b91c1c; }
.app-btn-secondary { color: #374151; background: #fff; border-color: #d1d5db; }
.app-btn-secondary:hover { background: #f9fafb; border-color: #9ca3af; }
.app-btn-soft { color: #1d4ed8; background: #eff6ff; border-color: #bfdbfe; }
.app-btn-soft:hover { background: #dbeafe; }

.app-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  line-height: 1rem;
  font-weight: 800;
  white-space: nowrap;
}

.app-empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--app-muted);
  background: #fff;
  border: 1px dashed #d1d5db;
  border-radius: 1rem;
}

.app-section-title {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: #111827;
  font-size: 1.05rem;
  line-height: 1.5rem;
  font-weight: 800;
}

.app-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--app-border);
  border-radius: 1rem;
  background: #fff;
}

.app-table {
  width: 100%;
  border-collapse: collapse;
}

.app-table th {
  padding: 0.8rem 1rem;
  color: #6b7280;
  background: #f9fafb;
  border-bottom: 1px solid var(--app-border);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: left;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.app-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: top;
}

.app-table tbody tr:last-child td { border-bottom: 0; }

.main-nav a[data-nav-link].is-active,
.main-nav button.is-active {
  color: #1d4ed8 !important;
  background: #dbeafe !important;
  border-color: #60a5fa !important;
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.22), 0 3px 10px rgba(37, 99, 235, 0.10);
}

.app-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: #bfdbfe transparent;
}

.app-scrollbar::-webkit-scrollbar { width: 7px; height: 7px; }
.app-scrollbar::-webkit-scrollbar-thumb { background: #bfdbfe; border-radius: 999px; }
.app-scrollbar::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 640px) {
  .app-shell { padding: 1rem; }
  .app-page-heading { padding: 1.15rem; }
  .app-btn { width: 100%; }
}

/* Pola z ikoną po lewej — osobne klasy zapobiegają nachodzeniu ikony na tekst. */
.app-icon-field {
  position: relative;
}

.app-input-icon {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 1;
  width: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  pointer-events: none;
}

.app-input-icon-compact {
  width: 2.5rem;
}

.app-input-with-leading-icon {
  padding-left: 2.75rem !important;
}

.app-input-icon-compact + .app-input-with-leading-icon {
  padding-left: 2.5rem !important;
}

/* Logo jest elementem marki, a nie aktywnym przyciskiem menu. */
.app-brand-link {
  flex: 0 0 auto;
  padding: 0.1rem 0;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.app-brand-link:hover,
.app-brand-link:focus,
.app-brand-link:active {
  background: transparent !important;
  box-shadow: none !important;
  outline: none;
}

.app-brand-logo {
  display: block;
  width: auto;
  height: 2.55rem;
  max-width: 12rem;
  object-fit: contain;
  filter: none !important;
  box-shadow: none !important;
}

.login-brand-logo {
  display: block;
  width: min(100%, 19rem);
  height: auto;
  max-height: 5.25rem;
  object-fit: contain;
  filter: none;
  box-shadow: none;
}

@media (max-width: 640px) {
  .app-brand-logo {
    height: 2.2rem;
    max-width: 9.5rem;
  }

  .login-brand-logo {
    width: min(100%, 16rem);
    max-height: 4.5rem;
  }
}

/* Karty licencji: daty i działania pozostają zawsze wewnątrz karty. */
.license-card-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  min-width: 0;
}

.license-card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
}

.license-date-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  flex: 1 1 18rem;
  min-width: 0;
}

.license-card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  flex: 0 1 auto;
  min-width: min(100%, 13rem);
}

.license-card-actions .app-btn {
  width: 100%;
  min-width: 0;
  white-space: nowrap;
}

@media (min-width: 1280px) {
  .license-card-layout {
    grid-template-columns: minmax(0, 1fr) minmax(22rem, 30rem);
    align-items: center;
  }

  .license-card-footer {
    flex-wrap: nowrap;
  }

  .license-card-actions {
    grid-template-columns: 1fr;
    min-width: 7.5rem;
  }
}

@media (max-width: 520px) {
  .license-date-grid,
  .license-card-actions {
    grid-template-columns: 1fr;
    flex-basis: 100%;
  }
}

/* Spójne zakładki Panelu kontrahenta. */
.app-tabs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.45rem;
  overflow-x: auto;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  background: #f8fafc;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
  scrollbar-width: thin;
  scrollbar-color: #bfdbfe transparent;
}

.app-tabs::-webkit-scrollbar { height: 5px; }
.app-tabs::-webkit-scrollbar-thumb { background: #bfdbfe; border-radius: 999px; }
.app-tabs::-webkit-scrollbar-track { background: transparent; }

.app-tabs .tab-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.6rem;
  padding: 0.62rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 0.75rem;
  background: transparent;
  color: #4b5563;
  font-size: 0.875rem;
  line-height: 1.1rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.app-tabs .tab-button:hover {
  color: #1d4ed8;
  background: #fff;
  border-color: #dbeafe;
}

.app-tabs .tab-button.active {
  color: #fff;
  background: #2563eb;
  border-color: #2563eb;
  box-shadow: 0 5px 14px rgba(37, 99, 235, 0.2);
}

.app-tabs .tab-button i {
  width: 1rem;
  text-align: center;
}

/* Spójne sekcje i tabele w zakładkach Panelu kontrahenta. */
.panel-tab-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Klasa komponentu nie może nadpisywać ukrywania nieaktywnej zakładki. */
.panel-tab-section.hidden {
  display: none !important;
}

.panel-tab-heading,
.panel-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.panel-tab-heading {
  padding: 0.25rem 0;
}

.panel-section-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e5e7eb;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.panel-section-icon {
  width: 2.5rem;
  height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border: 1px solid #dbeafe;
  border-radius: 0.8rem;
  color: #1d4ed8;
  background: #eff6ff;
}

.panel-section-title {
  margin: 0;
  color: #111827;
  font-size: 1.05rem;
  line-height: 1.35rem;
  font-weight: 800;
}

.panel-section-subtitle {
  margin: 0.2rem 0 0;
  color: #6b7280;
  font-size: 0.8rem;
  line-height: 1.2rem;
}

.panel-header-action {
  flex: 0 0 auto;
  white-space: nowrap;
}

.panel-table-wrap {
  overflow: auto;
  box-shadow: 0 5px 18px rgba(15, 23, 42, 0.045);
}

.panel-table {
  min-width: 44rem;
  table-layout: auto;
}

.panel-table-wide {
  min-width: 58rem;
}

.panel-table-compact {
  min-width: 34rem;
}

.panel-table th {
  white-space: nowrap;
}

.panel-table td {
  color: #374151;
  font-size: 0.875rem;
  line-height: 1.35rem;
}

.panel-table tbody tr {
  transition: background 140ms ease;
}

.panel-table tbody tr:hover {
  background: #f8fafc;
}

.panel-table-primary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  color: #111827;
  font-weight: 750;
}

.panel-table-primary > span {
  min-width: 0;
}

.panel-table-secondary {
  margin: 0.3rem 0 0 1.55rem;
  color: #6b7280;
  font-size: 0.75rem;
  line-height: 1.1rem;
}

.panel-table-link {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.45rem;
  color: #2563eb;
  font-weight: 750;
  text-decoration: none;
}

.panel-table-link:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

.panel-number {
  display: inline-block;
  color: #374151;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.panel-cell-number {
  text-align: right !important;
  white-space: nowrap;
}

.panel-cell-actions {
  text-align: right !important;
  white-space: nowrap;
}

.panel-table-action {
  min-height: 2.25rem;
  padding: 0.45rem 0.7rem;
  font-size: 0.78rem;
}

.panel-description-cell {
  min-width: 13rem;
  max-width: 32rem;
}

.panel-description {
  margin: 0;
  color: #4b5563;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.panel-date-range {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  white-space: nowrap;
}

.panel-date-range span {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.panel-date-range small {
  color: #9ca3af;
  font-size: 0.65rem;
  line-height: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.panel-date-range strong {
  color: #374151;
  font-variant-numeric: tabular-nums;
}

.panel-empty {
  min-height: 8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1.5rem;
  color: #6b7280;
  text-align: center;
  background: #fff;
}

.panel-empty > i {
  color: #93c5fd;
  font-size: 1.5rem;
}

.panel-empty-small {
  min-height: 6rem;
  border: 1px dashed #d1d5db;
  border-radius: 0.85rem;
  background: #f9fafb;
}

.panel-detail-list {
  display: flex;
  flex-direction: column;
}

.panel-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid #f3f4f6;
}

.panel-detail-row:first-child {
  padding-top: 0;
}

.panel-detail-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.panel-detail-row dt {
  color: #6b7280;
  font-size: 0.85rem;
}

.panel-detail-row dd {
  margin: 0;
  color: #111827;
  font-weight: 800;
  text-align: right;
}

.panel-contact-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.85rem;
  background: #f9fafb;
}

.panel-contact-avatar {
  width: 2.35rem;
  height: 2.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 0.75rem;
  color: #1d4ed8;
  background: #dbeafe;
}

.panel-mini-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid;
  border-radius: 0.9rem;
}

.panel-mini-stat span {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 800;
}

.panel-mini-stat strong {
  font-size: 1.35rem;
  line-height: 1.6rem;
  font-variant-numeric: tabular-nums;
}

.panel-mini-stat-blue { color: #1d4ed8; background: #eff6ff; border-color: #dbeafe; }
.panel-mini-stat-amber { color: #b45309; background: #fffbeb; border-color: #fde68a; }
.panel-mini-stat-green { color: #15803d; background: #f0fdf4; border-color: #bbf7d0; }

@media (max-width: 640px) {
  .panel-tab-heading,
  .panel-section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-header-action {
    width: 100%;
  }

  .panel-detail-row {
    align-items: flex-start;
  }

  .panel-table-wrap {
    margin-left: -1px;
    margin-right: -1px;
  }
}

/* Dokumentacja */
.dokumentacja-stat-grid {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

.dokumentacja-stat-icon {
  width: 2.75rem;
  height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.9rem;
  flex: 0 0 auto;
  font-size: 1.05rem;
}

.dokumentacja-layout {
  display: grid;
  grid-template-columns: minmax(15rem, 18rem) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.dokumentacja-sidebar {
  position: sticky;
  top: 1rem;
  overflow: visible;
}

.dokumentacja-sidebar-header,
.dokumentacja-toolbar,
.dokumentacja-folder-admin,
.dokumentacja-editor-toolbar,
.dokumentacja-document-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.dokumentacja-sidebar-header {
  padding: 1.15rem 1.15rem 0.9rem;
  border-bottom: 1px solid #f3f4f6;
}

.dokumentacja-folder-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.75rem;
  max-height: calc(100vh - 18rem);
  overflow-y: auto;
}

.dokumentacja-folder-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem;
  border: 1px solid transparent;
  border-radius: 0.85rem;
  color: #374151;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.dokumentacja-folder-link:hover {
  color: #1d4ed8;
  background: #f8fafc;
  border-color: #dbeafe;
}

.dokumentacja-folder-link.active {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.dokumentacja-folder-link strong {
  color: inherit;
  font-size: 0.85rem;
}

.dokumentacja-folder-link small {
  display: block;
  margin-top: 0.1rem;
  color: #9ca3af;
  font-size: 0.68rem;
}

.dokumentacja-folder-icon {
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  flex: 0 0 auto;
}

.dokumentacja-folder-count {
  min-width: 1.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  color: #6b7280;
  background: #f3f4f6;
  font-size: 0.68rem;
  font-weight: 800;
  text-align: center;
}

.dokumentacja-folder-link.active .dokumentacja-folder-count {
  color: #1d4ed8;
  background: #dbeafe;
}

.dokumentacja-folder-divider {
  height: 1px;
  margin: 0.35rem 0.5rem;
  background: #f3f4f6;
}

.dokumentacja-new-folder {
  padding: 0.85rem;
  border-top: 1px solid #f3f4f6;
}

.dokumentacja-new-folder summary,
.dokumentacja-folder-admin summary {
  list-style: none;
}

.dokumentacja-new-folder summary::-webkit-details-marker,
.dokumentacja-folder-admin summary::-webkit-details-marker {
  display: none;
}

.dokumentacja-toolbar,
.dokumentacja-folder-admin {
  padding: 1.15rem;
}

.dokumentacja-search {
  position: relative;
  width: min(100%, 32rem);
}

.dokumentacja-search-clear {
  position: absolute;
  right: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.8rem;
  height: 1.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #6b7280;
  background: #f3f4f6;
}

.dokumentacja-folder-admin {
  position: relative;
  border-color: #fde68a;
  background: linear-gradient(135deg, #fffbeb, #ffffff 70%);
}

.dokumentacja-folder-menu {
  position: absolute;
  z-index: 30;
  right: 0;
  top: calc(100% + 0.5rem);
  width: min(21rem, calc(100vw - 2rem));
  padding: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.16);
}

.dokumentacja-note-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 1rem;
}

.dokumentacja-note-card {
  min-width: 0;
  overflow: hidden;
}

.dokumentacja-note-main {
  display: block;
  padding: 1.2rem;
  color: inherit;
  text-decoration: none;
}

.dokumentacja-file-icon {
  width: 2.8rem;
  height: 2.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.9rem;
  color: #1d4ed8;
  background: #eff6ff;
  font-size: 1.1rem;
}

.dokumentacja-note-title {
  margin-top: 1rem;
  color: #111827;
  font-size: 1.05rem;
  line-height: 1.4rem;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.dokumentacja-note-preview {
  min-height: 3.75rem;
  margin-top: 0.6rem;
  color: #6b7280;
  font-size: 0.84rem;
  line-height: 1.25rem;
  overflow-wrap: anywhere;
}

.dokumentacja-note-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.2rem;
  border-top: 1px solid #f3f4f6;
  background: #f9fafb;
}

.dokumentacja-empty {
  min-height: 22rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.dokumentacja-empty-icon {
  width: 4rem;
  height: 4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 1.25rem;
  color: #2563eb;
  background: #eff6ff;
  font-size: 1.5rem;
}

.dokumentacja-form-shell {
  max-width: 1180px;
}

.dokumentacja-editor-toolbar,
.dokumentacja-document-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}

.dokumentacja-code-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
}

.dokumentacja-code-dots i {
  width: 0.65rem;
  height: 0.65rem;
  display: block;
  border-radius: 999px;
  background: #d1d5db;
}

.dokumentacja-code-dots i:nth-child(1) { background: #f87171; }
.dokumentacja-code-dots i:nth-child(2) { background: #fbbf24; }
.dokumentacja-code-dots i:nth-child(3) { background: #34d399; }

.dokumentacja-editor {
  min-height: 32rem;
  padding: 1.1rem;
  color: #d1d5db;
  background: #111827;
  border-color: #1f2937;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
  line-height: 1.55rem;
  tab-size: 2;
}

.dokumentacja-editor:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

.dokumentacja-document-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
}

.dokumentacja-document-meta > div {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.2rem;
  border-right: 1px solid #f3f4f6;
}

.dokumentacja-document-meta > div:last-child { border-right: 0; }
.dokumentacja-document-meta span { color: #9ca3af; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.dokumentacja-document-meta strong { color: #111827; font-size: 0.88rem; overflow-wrap: anywhere; }
.dokumentacja-document-meta small { color: #6b7280; font-size: 0.72rem; }

.dokumentacja-document {
  overflow: hidden;
}

.dokumentacja-document-content {
  min-height: 22rem;
  margin: 0;
  padding: 1.5rem;
  overflow: auto;
  color: #d1d5db;
  background: #111827;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
  line-height: 1.55rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}

.dokumentacja-toast {
  position: fixed;
  z-index: 100;
  right: 1.25rem;
  bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1rem;
  border-radius: 0.85rem;
  color: #fff;
  background: #111827;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.22);
  opacity: 0;
  transform: translateY(0.75rem);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.dokumentacja-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Podgląd haseł w panelu kontrahenta */
.panel-access-table {
  min-width: 76rem;
}

.panel-secret-field {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 15rem;
  padding: 0.35rem 0.4rem 0.35rem 0.7rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  background: #f9fafb;
}

.panel-secret-input {
  width: 8.5rem;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #111827;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  font-weight: 700;
}

.panel-secret-button,
.panel-note-button {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #dbeafe;
  border-radius: 0.6rem;
  color: #1d4ed8;
  background: #eff6ff;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}

.panel-secret-button:hover,
.panel-note-button:hover {
  color: #1e40af;
  background: #dbeafe;
  transform: translateY(-1px);
}

.panel-note-button {
  border-color: #fde68a;
  color: #b45309;
  background: #fffbeb;
}

.panel-note-button:hover {
  color: #92400e;
  background: #fef3c7;
}

.panel-access-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
}

.panel-access-modal.hidden { display: none; }

.panel-access-modal-card {
  width: min(100%, 36rem);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}

@media (min-width: 640px) {
  .dokumentacja-stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dokumentacja-note-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1280px) {
  .dokumentacja-note-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1023px) {
  .dokumentacja-layout { grid-template-columns: minmax(0, 1fr); }
  .dokumentacja-sidebar {
    position: fixed;
    z-index: 80;
    inset: 0 auto 0 0;
    width: min(20rem, calc(100vw - 2rem));
    border-radius: 0 1rem 1rem 0;
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }
  .dokumentacja-sidebar.is-open { transform: translateX(0); }
  .dokumentacja-folder-list { max-height: calc(100vh - 12rem); }
}

@media (max-width: 767px) {
  .dokumentacja-toolbar,
  .dokumentacja-folder-admin,
  .dokumentacja-editor-toolbar,
  .dokumentacja-document-header {
    align-items: stretch;
    flex-direction: column;
  }
  .dokumentacja-search { width: 100%; }
  .dokumentacja-note-footer { align-items: flex-start; flex-direction: column; }
  .dokumentacja-document-meta { grid-template-columns: minmax(0, 1fr); }
  .dokumentacja-document-meta > div { border-right: 0; border-bottom: 1px solid #f3f4f6; }
  .dokumentacja-document-meta > div:last-child { border-bottom: 0; }
  .dokumentacja-editor { min-height: 24rem; }
}

/* Typy dokumentów i załączniki */
.dokumentacja-type-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.dokumentacja-type-option {
  display: block;
  cursor: pointer;
}

.dokumentacja-type-radio {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.dokumentacja-type-card {
  min-height: 6rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  background: #fff;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.dokumentacja-type-option:hover .dokumentacja-type-card {
  border-color: #bfdbfe;
  background: #f8fbff;
  transform: translateY(-1px);
}

.dokumentacja-type-radio:focus + .dokumentacja-type-card {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.dokumentacja-type-radio:checked + .dokumentacja-type-card {
  border-color: #60a5fa;
  background: #eff6ff;
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.1);
}

.dokumentacja-type-card strong {
  display: block;
  color: #111827;
  font-size: 0.95rem;
  font-weight: 850;
}

.dokumentacja-type-card small {
  display: block;
  margin-top: 0.2rem;
  color: #6b7280;
  font-size: 0.75rem;
  line-height: 1.1rem;
}

.dokumentacja-type-icon,
.dokumentacja-section-icon,
.dokumentacja-attachment-icon,
.dokumentacja-upload-icon {
  width: 2.65rem;
  height: 2.65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.85rem;
  color: #1d4ed8;
  background: #eff6ff;
  flex: 0 0 auto;
}

.dokumentacja-type-icon.is-note,
.dokumentacja-section-icon.is-note {
  color: #a16207;
  background: #fefce8;
}

.dokumentacja-type-icon.is-script {
  color: #1d4ed8;
  background: #eff6ff;
}

.dokumentacja-type-check {
  color: #2563eb;
  opacity: 0;
  transform: scale(0.75);
  transition: opacity 150ms ease, transform 150ms ease;
}

.dokumentacja-type-radio:checked + .dokumentacja-type-card .dokumentacja-type-check {
  opacity: 1;
  transform: scale(1);
}

.dokumentacja-editor.is-note {
  color: #1f2937;
  background: #fff;
  border-color: #d1d5db;
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.6rem;
}

.dokumentacja-editor.is-note:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.18);
}

.dokumentacja-document-content.is-note {
  min-height: 12rem;
  color: #1f2937;
  background: #fff;
  font-family: inherit;
  font-size: 0.94rem;
  line-height: 1.7rem;
}

.dokumentacja-file-icon.is-note {
  color: #a16207;
  background: #fefce8;
}

.dokumentacja-file-icon.is-script {
  color: #1d4ed8;
  background: #eff6ff;
}

.dokumentacja-note-date {
  display: block;
  margin-top: 0.8rem;
  color: #9ca3af;
  font-size: 0.72rem;
  font-weight: 700;
}

.dokumentacja-upload-dropzone {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border: 1px dashed #93c5fd;
  border-radius: 1rem;
  color: #374151;
  background: #f8fbff;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}

.dokumentacja-upload-dropzone:hover {
  border-color: #2563eb;
  background: #eff6ff;
}

.dokumentacja-upload-dropzone strong {
  display: block;
  color: #111827;
  font-size: 0.88rem;
}

.dokumentacja-upload-dropzone small {
  display: block;
  margin-top: 0.2rem;
  color: #6b7280;
  font-size: 0.73rem;
}

.dokumentacja-upload-dropzone.is-compact {
  grid-template-columns: auto minmax(0, 1fr);
  padding: 0.85rem;
}

.dokumentacja-selected-files {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.dokumentacja-selected-files:empty {
  display: none;
}

.dokumentacja-selected-file {
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.65rem;
  border: 1px solid #dbeafe;
  border-radius: 0.7rem;
  color: #1e40af;
  background: #eff6ff;
  font-size: 0.74rem;
  font-weight: 700;
}

.dokumentacja-selected-file span {
  max-width: 18rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dokumentacja-selected-file small {
  color: #6b7280;
  font-weight: 600;
}

.dokumentacja-existing-files {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0.8rem;
}

.dokumentacja-existing-file {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  padding: 0.65rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.85rem;
  color: #374151;
  background: #fff;
  text-decoration: none;
}

.dokumentacja-existing-file:hover {
  border-color: #bfdbfe;
  color: #1d4ed8;
  background: #f8fbff;
}

.dokumentacja-existing-file .dokumentacja-attachment-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.7rem;
}

.dokumentacja-existing-file strong {
  font-size: 0.78rem;
}

.dokumentacja-existing-file small {
  color: #9ca3af;
  font-size: 0.68rem;
}

.dokumentacja-attachments-card {
  overflow: visible;
}

.dokumentacja-attachments-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.2rem;
  border-bottom: 1px solid #f3f4f6;
}

.dokumentacja-upload-menu {
  position: relative;
  flex: 0 0 auto;
}

.dokumentacja-upload-menu > summary {
  list-style: none;
}

.dokumentacja-upload-menu > summary::-webkit-details-marker {
  display: none;
}

.dokumentacja-upload-panel {
  position: absolute;
  z-index: 40;
  right: 0;
  top: calc(100% + 0.55rem);
  width: min(28rem, calc(100vw - 2rem));
  padding: 1rem;
  border: 1px solid #dbeafe;
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
}

.dokumentacja-upload-panel .dokumentacja-selected-files {
  margin-bottom: 0.75rem;
}

.dokumentacja-attachment-list {
  display: flex;
  flex-direction: column;
}

.dokumentacja-attachment-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid #f3f4f6;
}

.dokumentacja-attachment-row:last-child {
  border-bottom: 0;
}

.dokumentacja-attachment-row:hover {
  background: #f9fafb;
}

.dokumentacja-attachment-icon {
  width: 2.45rem;
  height: 2.45rem;
  color: #4b5563;
  background: #f3f4f6;
}

.dokumentacja-attachment-info {
  min-width: 0;
}

.dokumentacja-attachment-info strong {
  display: block;
  color: #111827;
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.dokumentacja-attachment-info span {
  display: block;
  margin-top: 0.15rem;
  color: #9ca3af;
  font-size: 0.7rem;
}

.dokumentacja-attachment-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-icon-btn {
  width: 2.35rem;
  height: 2.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  color: #4b5563;
  background: #fff;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.app-icon-btn:hover {
  color: #1d4ed8;
  border-color: #bfdbfe;
  background: #eff6ff;
}

.app-icon-btn.danger {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fff;
}

.app-icon-btn.danger:hover {
  color: #991b1b;
  background: #fef2f2;
}

.dokumentacja-attachments-empty {
  min-height: 8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1.5rem;
  color: #9ca3af;
  text-align: center;
}

.dokumentacja-attachments-empty i {
  font-size: 1.65rem;
  color: #bfdbfe;
}

@media (min-width: 640px) {
  .dokumentacja-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .dokumentacja-stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dokumentacja-document-meta { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
  .dokumentacja-type-grid,
  .dokumentacja-existing-files {
    grid-template-columns: minmax(0, 1fr);
  }

  .dokumentacja-upload-dropzone {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .dokumentacja-upload-dropzone > .app-btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .dokumentacja-attachments-header {
    align-items: stretch;
    flex-direction: column;
  }

  .dokumentacja-upload-menu,
  .dokumentacja-upload-menu > summary {
    width: 100%;
  }

  .dokumentacja-upload-panel {
    position: static;
    width: 100%;
    margin-top: 0.65rem;
    box-shadow: none;
  }

  .dokumentacja-attachment-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .dokumentacja-attachment-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}
