:root {
  /* Brand palette - Pastelowe kolory z fioletowym jako głównym */
  --bg: #F7F9FB;
  --panel: #FFFFFF;
  --panel-alt: #dec8ff;
  --text: #0F172A;
  --muted: #475569;
  
  /* Główny kolor fioletowy - pastelowy */
  --accent: #aa82e6;
  --accent-hover: #c2a9e9;
  --accent-dark: #8b5bd4;
  --main-color: var(--accent);
  --main-color-rgb: 170, 130, 230;
  
  --border: #E5E7EB;
  --highlight: #f6f0ff;
  
  /* Pastelowa paleta dla statusów - jasne tła z ciemnymi czcionkami */
  --success: #d4f4dd;
  --success-text: #0d7d3a;
  --info: #d1ecf1;
  --info-text: #0c5460;
  --warning: #fff3cd;
  --warning-text: #856404;
  --danger: #f8d7da;
  --danger-text: #721c24;
  
  --badge-font-size: 0.75rem;

  /* Radii & shadows */
  --radius-card: 12px;
  --radius-control: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);

  /* Application layout */
  --tb-sidebar-w: 256px;
  --tb-topbar-h: 60px;
}

html,
body {
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.5;
  font-size: 16px;
}

h1 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
}

h2 {
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
}

h3 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

h4 {
  font-size: 1.125rem;
  margin-bottom: 0.75rem;
}

h5 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

h6 {
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--text);
  line-height: 1.25;
  font-weight: 600;
}

p,
ul,
ol,
li {
  color: var(--text);
}

.text-muted {
  color: var(--muted) !important;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: none;
}

.btn,
.form-control,
.form-select,
.input-group-text {
  border-radius: var(--radius-control);
}

/* Przyciski - główny kolor fioletowy pastelowy */
.btn-primary {
  --bs-btn-bg: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: var(--accent-dark);
  --bs-btn-hover-border-color: var(--accent-dark);
  --bs-btn-focus-shadow-rgb: var(--main-color-rgb);
  --bs-btn-color: #ffffff;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.08);
}

.btn-outline-primary {
  --bs-btn-color: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: var(--accent);
  --bs-btn-hover-border-color: var(--accent);
  --bs-btn-hover-color: #fff;
}

/* Przyciski Success - pastelowy zielony */
.btn-success {
  --bs-btn-bg: #a8e6b7;
  --bs-btn-border-color: #a8e6b7;
  --bs-btn-hover-bg: #8cd49c;
  --bs-btn-hover-border-color: #8cd49c;
  --bs-btn-color: #0d7d3a;
  --bs-btn-hover-color: #0d7d3a;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.08);
}

.btn-outline-success {
  --bs-btn-color: #0d7d3a;
  --bs-btn-border-color: #a8e6b7;
  --bs-btn-hover-bg: #a8e6b7;
  --bs-btn-hover-border-color: #a8e6b7;
  --bs-btn-hover-color: #0d7d3a;
}

/* Przyciski Info - pastelowy niebieski */
.btn-info {
  --bs-btn-bg: #b3e5f0;
  --bs-btn-border-color: #b3e5f0;
  --bs-btn-hover-bg: #8dd4e3;
  --bs-btn-hover-border-color: #8dd4e3;
  --bs-btn-color: #0c5460;
  --bs-btn-hover-color: #0c5460;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.08);
}

.btn-outline-info {
  --bs-btn-color: #0c5460;
  --bs-btn-border-color: #b3e5f0;
  --bs-btn-hover-bg: #b3e5f0;
  --bs-btn-hover-border-color: #b3e5f0;
  --bs-btn-hover-color: #0c5460;
}

/* Przyciski Warning - pastelowy żółty */
.btn-warning {
  --bs-btn-bg: #ffe69c;
  --bs-btn-border-color: #ffe69c;
  --bs-btn-hover-bg: #ffd966;
  --bs-btn-hover-border-color: #ffd966;
  --bs-btn-color: #856404;
  --bs-btn-hover-color: #856404;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.08);
}

.btn-outline-warning {
  --bs-btn-color: #856404;
  --bs-btn-border-color: #ffe69c;
  --bs-btn-hover-bg: #ffe69c;
  --bs-btn-hover-border-color: #ffe69c;
  --bs-btn-hover-color: #856404;
}

/* Przyciski Danger - pastelowy czerwony */
.btn-danger {
  --bs-btn-bg: #f5b5bb;
  --bs-btn-border-color: #f5b5bb;
  --bs-btn-hover-bg: #f08a94;
  --bs-btn-hover-border-color: #f08a94;
  --bs-btn-color: #721c24;
  --bs-btn-hover-color: #721c24;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.08);
}

.btn-outline-danger {
  --bs-btn-color: #721c24;
  --bs-btn-border-color: #f5b5bb;
  --bs-btn-hover-bg: #f5b5bb;
  --bs-btn-hover-border-color: #f5b5bb;
  --bs-btn-hover-color: #721c24;
}

.btn:focus,
.form-control:focus,
.form-select:focus,
.nav-link:focus,
.btn-check:focus + .btn {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: none;
}

.form-control,
.form-select {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
}

.form-control:disabled,
.form-select:disabled {
  background: var(--panel-alt);
  color: var(--muted);
}

.card,
.modal-content,
.offcanvas,
.dropdown-menu,
.list-group,
.toast {
  background: var(--panel);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* Custom width for offcanvas edit panels - 2x Bootstrap default (400px -> 800px) */
.offcanvas-end {
  width: 800px !important;
  max-width: 90%;
}

/* Responsive: smaller screens get full width */
@media (max-width: 992px) {
  .offcanvas-end {
    width: 85% !important;
  }
}

@media (max-width: 576px) {
  .offcanvas-end {
    width: 100% !important;
  }
}

.recent-activity-list .recent-activity-item {
  padding: 0.85rem 1.25rem;
  border-color: color-mix(in srgb, var(--border) 85%, white) !important;
}

.recent-activity-list .recent-activity-item:last-child {
  border-bottom: none !important;
}

.list-pagination {
  margin-top: 1.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.list-pagination .pagination {
  gap: 0.5rem;
}

.list-pagination .page-link {
  border-radius: var(--radius-control);
  min-width: 2.5rem;
  text-align: center;
  background-color: #ffffff;
  border: 1px solid var(--border);
  color: var(--text);
  transition: all 0.15s ease;
}

.list-pagination .page-link:hover {
  background-color: color-mix(in srgb, var(--accent) 10%, white);
  border-color: var(--accent);
  color: var(--accent);
}

.list-pagination .page-item.active .page-link {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 500;
}

/* Pozostałe disabled (numery) - musi być przed specific selectors */
.list-pagination .page-item.disabled .page-link {
  background-color: transparent;
  border-color: var(--border);
  color: var(--muted);
  opacity: 0.5;
}

/* Previous/Next przyciski - transparentne z fioletową ramką i tekstem */
/* NOT disabled - używamy :not() aby wykluczyć disabled */
.list-pagination .page-item:first-child:not(.disabled) .page-link,
.list-pagination .page-item:last-child:not(.disabled) .page-link {
  background-color: transparent !important;
  border: 1px solid var(--accent) !important;
  color: var(--accent) !important;
  font-weight: 500;
  opacity: 1 !important;
}

.list-pagination .page-item:first-child:not(.disabled) .page-link:hover,
.list-pagination .page-item:last-child:not(.disabled) .page-link:hover {
  background-color: color-mix(in srgb, var(--accent) 10%, white) !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

/* Previous/Next disabled - szare (wyższa specyficzność niż ogólny disabled) */
.list-pagination .page-item.disabled:first-child .page-link,
.list-pagination .page-item.disabled:last-child .page-link {
  background-color: transparent !important;
  border-color: var(--border) !important;
  color: var(--muted) !important;
  opacity: 0.5 !important;
}

.card .card-body {
  padding: 16px;
}

.card + .card,
.card + .page-section,
.page-section + .card {
  margin-top: 1.5rem;
}

.section {
  padding: 64px 0;
}

.bg-subtle {
  background: var(--panel-alt) !important;
}

code,
pre {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.125rem 0.375rem;
  font-family: "JetBrains Mono", "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.table {
  --bs-table-bg: var(--panel);
  --bs-table-border-color: var(--border);
  color: var(--text);
  margin-bottom: 0;
}

.table-striped > tbody > tr:nth-of-type(odd) {
  background-color: var(--panel-alt);
}

.table thead th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  background: var(--panel-alt);
}

.table tbody td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table-hover tbody tr:hover {
  background: color-mix(in srgb, var(--panel-alt) 70%, white);
}

.table-responsive {
  border-radius: 0 0 var(--radius-card) var(--radius-card);
}

/* Kolorowe wiersze tabel - pastelowe */
.table-success {
  background-color: var(--success) !important;
  color: var(--success-text) !important;
}

.table-info {
  background-color: var(--info) !important;
  color: var(--info-text) !important;
}

.table-warning {
  background-color: var(--warning) !important;
  color: #856404 !important;
}

.table-danger {
  background-color: var(--danger) !important;
  color: #721c24 !important;
}

/* Badge'e - pastelowe tła z ciemnymi czcionkami */
.badge {
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  font-size: var(--badge-font-size);
  line-height: 1;
}

.badge.bg-primary {
  background: var(--accent) !important;
  color: #ffffff !important;
}

.badge.bg-success {
  background: var(--success) !important;
  color: var(--success-text) !important;
}

.badge.bg-info {
  background: var(--info) !important;
  color: var(--info-text) !important;
}

.badge.bg-warning {
  background: var(--warning) !important;
  color: var(--warning-text) !important;
}

.badge.bg-danger {
  background: var(--danger) !important;
  color: var(--danger-text) !important;
}

.badge.bg-light {
  background: #f8f9fa !important;
  color: var(--text) !important;
}

.badge.bg-dark {
  background: #343a40 !important;
  color: #ffffff !important;
}

.badge.bg-secondary {
  background: #e9ecef !important;
  color: var(--muted) !important;
}

.docset-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--badge-font-size);
  font-weight: 500;
  color: var(--muted);
}

.docset-status-badge .badge {
  margin: 0;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.03em;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.04);
  font-size: var(--badge-font-size);
}

.alert-success {
  background: color-mix(in srgb, var(--success) 10%, white);
  border-color: color-mix(in srgb, var(--success) 35%, white);
  color: var(--success-text);
}

.alert-info {
  background: color-mix(in srgb, var(--info) 10%, white);
  border-color: color-mix(in srgb, var(--info) 35%, white);
  color: var(--info-text);
}

.alert-warning {
  background: color-mix(in srgb, var(--warning) 12%, white);
  border-color: color-mix(in srgb, var(--warning) 40%, white);
  color: #856404;
}

.alert-danger {
  background: color-mix(in srgb, var(--danger) 10%, white);
  border-color: color-mix(in srgb, var(--danger) 35%, white);
  color: #721c24;
}

/* Layout shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-shell .sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  min-height: 100vh;
  color: var(--muted);
  width: var(--tb-sidebar-w);
  z-index: 1060;
  box-sizing: border-box;
}

.app-shell .sidebar .logo {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.app-shell .sidebar .nav-link {
  color: var(--muted);
  border-radius: var(--radius-control);
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.app-shell .sidebar .nav-link .bi {
  font-size: 1.1rem;
  color: var(--accent);
}

.app-shell .sidebar .nav-link:hover {
  background: var(--panel-alt);
  color: var(--text);
}

.app-shell .sidebar .nav-link.active {
  background: var(--highlight);
  color: var(--accent);
  font-weight: 600;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
}

.app-shell .sidebar .nav-link.active .bi {
  color: var(--accent);
}

.app-shell .sidebar .nav-link + ul.nav {
  margin-left: 1rem;
}

.app-shell .sidebar hr {
  border-color: var(--border);
  opacity: 1;
  margin: 0.5rem 0.75rem;
}

.app-shell .content {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-left: var(--tb-sidebar-w);
  min-height: 100vh;
  background: transparent;
}

.app-shell .main-container {
  width: 100%;
  padding: 2.5rem clamp(1.5rem, 4vw, 3rem);
  margin: 0 auto;
}

.app-shell .page-section {
  margin-bottom: 3rem;
}

.app-shell .page-section:last-child {
  margin-bottom: 0;
}

.app-shell .page-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.app-shell .page-header .page-title {
  margin-bottom: 0;
}

.app-shell .page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.app-shell .topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1050;
  box-shadow: var(--shadow-sm);
}

.app-shell .topbar .btn {
  border-radius: var(--radius-control);
}

.app-shell .main-container,
.app-shell main.container-fluid {
  max-width: 1440px;
}

.app-shell .user-switcher {
  min-width: 180px;
}

@media (max-width: 991.98px) {
  .app-shell .sidebar {
    min-height: auto;
    position: fixed;
    left: calc(-1 * var(--tb-sidebar-w));
    top: var(--tb-topbar-h);
    bottom: 0;
    width: var(--tb-sidebar-w);
    transition: left 0.2s ease-in-out;
    overflow-y: auto;
  }

  .app-shell .sidebar.show {
    left: 0;
  }

  .app-shell .content {
    margin-left: 0 !important;
    transform: translateX(0);
    transition: transform 0.2s ease-in-out;
  }

  .app-shell .content.sidebar-open {
    transform: translateX(var(--tb-sidebar-w));
  }
}

@media (min-width: 992px) {
  .app-shell .sidebar {
    position: fixed;
    top: 0;
    left: 0;
  }

  .app-shell .content {
    margin-left: var(--tb-sidebar-w);
  }
}

@media (max-width: 767.98px) {
  .app-shell .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .app-shell .page-actions {
    width: 100%;
  }

  .app-shell .main-container {
    padding: 2rem 1.25rem 2.5rem;
  }

  .app-shell .table-responsive {
    border-radius: var(--radius-card);
  }
}

.app-shell .sidebar-backdrop {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 1030;
}

.app-shell .sidebar-backdrop.show {
  display: block;
}

body.sidebar-open {
  overflow: hidden;
}

[id] {
  scroll-margin-top: calc(var(--tb-topbar-h, 56px) + 12px);
}

/* Custom controls */
.departments-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background-color: var(--panel);
  box-shadow: var(--shadow-sm);
}

.departments-checkboxes ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.departments-checkboxes li {
  margin: 0.5rem 0;
}

.departments-checkboxes label {
  display: flex;
  align-items: center;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
}

.departments-checkboxes input[type="checkbox"],
.form-check-input {
  width: 1.125rem;
  height: 1.125rem;
  margin-right: 0.75rem;
  cursor: pointer;
  accent-color: var(--accent);
}

.form-check-label {
  cursor: pointer;
}

/* Nested files / list helpers */
.nested-file {
  border-left: 3px solid color-mix(in srgb, var(--accent) 10%, var(--border)) !important;
  background-color: var(--panel-alt) !important;
}

.nested-file:hover {
  background-color: color-mix(in srgb, var(--panel-alt) 70%, white) !important;
}

.nested-file .badge {
  opacity: 0.85;
}

.nested-files-container {
  background-color: var(--panel-alt);
  border-left: 3px solid var(--accent);
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: var(--radius-control);
}

.nested-file-item {
  background-color: var(--panel);
  border: 1px solid var(--border);
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-sm);
}

.deep-nested-container {
  background-color: var(--panel);
  border-left: 2px solid color-mix(in srgb, var(--muted) 40%, white);
  margin-top: 0.5rem;
  padding: 0.25rem 0 0.25rem 0.5rem;
}

.list-group-item {
  overflow-x: hidden;
  word-wrap: break-word;
}

.badge-sm {
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
}

.card-header {
  border-radius: var(--radius-card) !important;
}

/* Card headers z kolorami - pastelowe */
.card-header.bg-primary {
  background: var(--accent) !important;
  color: #ffffff !important;
  border-color: var(--accent) !important;
}

.card-header.bg-success {
  background: #a8e6b7 !important;
  color: var(--success-text) !important;
  border-color: #a8e6b7 !important;
}

.card-header.bg-info {
  background: #b3e5f0 !important;
  color: var(--info-text) !important;
  border-color: #b3e5f0 !important;
}

.card-header.bg-warning {
  background: var(--warning) !important;
  color: var(--warning-text) !important;
  border-color: var(--warning) !important;
}

.card-header.bg-danger {
  background: var(--danger) !important;
  color: var(--danger-text) !important;
  border-color: var(--danger) !important;
}

.card-header.bg-light {
  background: var(--panel-alt) !important;
  color: var(--text) !important;
}

/* API status chips — keep original status colors */
.api-status {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-control);
  font-size: 0.875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.api-status.w-100 {
  border-radius: 0;
  padding: 1.25rem;
  background-color: var(--panel-alt);
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
  min-height: 70px;
  display: flex;
  align-items: center;
}

.api-status.disconnected.w-100 {
  background-color: #f8f9fa;
  color: #6c757d;
  border-top: 1px solid #dee2e6;
  border-bottom: 1px solid #dee2e6;
}

.api-status.connecting.w-100,
.api-status.syncing.w-100,
.api-status.uploading.w-100 {
  background-color: #fff3cd;
  color: #664d03;
  border-top: 1px solid #ffecb5;
  border-bottom: 1px solid #ffecb5;
}

.api-status.connected.w-100 {
  background-color: #d1ecf1;
  color: #0c5460;
  border-top: 1px solid #b8daff;
  border-bottom: 1px solid #b8daff;
}

.api-status.processing_required.w-100 {
  background-color: #fd7e14;
  color: #ffffff;
  border-top: 1px solid #fd7e14;
  border-bottom: 1px solid #fd7e14;
}

.api-status.processing.w-100,
.api-status.file_processing.w-100 {
  background-color: #e2e3e5;
  color: #383d41;
  border-top: 1px solid #d6d8db;
  border-bottom: 1px solid #d6d8db;
}

.api-status.completed.w-100,
.api-status.ready_for_querying.w-100 {
  background-color: #d4edda;
  color: #155724;
  border-top: 1px solid #c3e6cb;
  border-bottom: 1px solid #c3e6cb;
}

.api-status.error.w-100,
.api-status.failed_processing.w-100,
.api-status.failed.w-100 {
  background-color: #f8d7da;
  color: #721c24;
  border-top: 1px solid #f5c6cb;
  border-bottom: 1px solid #f5c6cb;
}

.api-status.unsynchronized.w-100,
.api-status.files_uploaded.w-100 {
  background-color: #fff3cd;
  color: #664d03;
  border-top: 1px solid #ffecb5;
  border-bottom: 1px solid #ffecb5;
}

.api-status.stale.w-100 {
  background-color: #ffe5d0;
  color: #7a3a00;
  border-top: 1px solid #ffd2ad;
  border-bottom: 1px solid #ffd2ad;
}

.api-status.cancelled_by_user.w-100,
.api-status.cancelled.w-100 {
  background-color: #e2e3e5;
  color: #343a40;
  border-top: 1px solid #d6d8db;
  border-bottom: 1px solid #d6d8db;
}

.api-status.empty.w-100 {
  background-color: #f8f9fa;
  color: #6c757d;
  border-top: 1px solid #dee2e6;
  border-bottom: 1px solid #dee2e6;
}

/* Nowe statusy dla bezpiecznej synchronizacji */
.api-status.api_unavailable.w-100 {
  background-color: #cce5ff;
  color: #004085;
  border-top: 1px solid #b8daff;
  border-bottom: 1px solid #b8daff;
}

.api-status.invalid.w-100 {
  background-color: #f8d7da;
  color: #721c24;
  border-top: 1px solid #f5c6cb;
  border-bottom: 1px solid #f5c6cb;
}

.api-status.sync_error.w-100 {
  background-color: #ffe5d0;
  color: #7a3a00;
  border-top: 1px solid #ffd2ad;
  border-bottom: 1px solid #ffd2ad;
}

.api-status.disconnected {
  background-color: #f8f9fa;
  color: #6c757d;
  border: 1px solid #dee2e6;
}

.api-status.connecting,
.api-status.syncing,
.api-status.uploading {
  background-color: #fff3cd;
  color: #664d03;
  border: 1px solid #ffecb5;
}

.api-status.connected {
  background-color: #d1ecf1;
  color: #0c5460;
  border: 1px solid #b8daff;
}

.api-status.processing {
  background-color: #e2e3e5;
  color: #383d41;
  border: 1px solid #d6d8db;
}

.api-status.completed {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.api-status.error {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.api-status .spinner-border {
  width: 0.875rem;
  height: 0.875rem;
  border-width: 0.125rem;
}

.api-progress {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.api-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  justify-content: flex-start;
}

.api-controls .btn {
  font-size: 0.875rem;
  padding: 0.375rem 0.75rem;
  text-align: center;
  min-width: 140px;
}

.api-config-warning {
  background-color: #fff3cd;
  border: 1px solid #ffecb5;
  color: #664d03;
  border-radius: var(--radius-control);
  padding: 0.75rem;
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

.api-config-warning .bi {
  color: #f0ad4e;
}

.htmx-indicator {
  opacity: 0;
  transition: opacity 200ms ease-in;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

#form-filters,
#form-filters .row {
  border: none !important;
  outline: none !important;
}

.accordion-button:not(.collapsed),
.accordion-button.active {
  background: var(--accent);
  color: #fff;
  box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.1);
}

.accordion-button:focus {
  box-shadow: 0 0 0 0.2rem rgba(var(--main-color-rgb), 0.2);
}

.accordion-item {
  border-radius: var(--radius-card) !important;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}

.accordion-item:last-child {
  margin-bottom: 0;
}

.tb-dropzone {
  border: 2px dashed color-mix(in srgb, var(--border) 60%, #94a3b8);
  border-radius: var(--radius-card);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all .15s ease-in-out;
  background: var(--panel);
}

.tb-dropzone.active {
  border-color: var(--accent);
  background-color: color-mix(in srgb, var(--accent) 10%, white);
}

/* Utility tweaks */
.hr,
hr {
  border-color: var(--border);
}

.bg-white {
  background: #fff;
}

.shadow-sm {
  box-shadow: var(--shadow-sm) !important;
}

.shadow-md {
  box-shadow: var(--shadow-md) !important;
}

.gap-xs {
  gap: 0.5rem;
}

.gap-sm {
  gap: 0.75rem;
}

.gap-md {
  gap: 1rem;
}

.text-xs {
  font-size: 0.75rem;
}

.text-sm {
  font-size: 0.875rem;
}

.text-lg {
  font-size: 1.125rem;
}

.muted {
  color: var(--muted);
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ========================================
   READ-ONLY MODE STYLES
   ======================================== */

/* Banner at bottom of page for read-only users */
.read-only-banner {
  background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
  border-top: 2px solid #ffc107;
  color: #856404;
  padding: 0.5rem 1rem;
  text-align: center;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  position: fixed;
  bottom: 50px; /* Above AI disclaimer footer */
  left: var(--tb-sidebar-w, 250px);
  right: 0;
  z-index: 1001;
}

.read-only-banner i {
  font-size: 1rem;
}

/* Mobile - banner takes full width */
@media (max-width: 991.98px) {
  .read-only-banner {
    left: 0;
  }
}

/* Shift app-shell down when banner is present */
body.read-only-mode .app-shell {
  /* Banner height compensation handled by sticky */
}

/* Style for action buttons in read-only mode */
body.read-only-mode .requires-write,
body.read-only-mode .btn-requires-write,
body.read-only-mode [data-requires-write="true"] {
  opacity: 0.5;
  cursor: not-allowed !important;
  pointer-events: none;
  position: relative;
}

/* Alternative: pointer-events auto but with visual feedback */
body.read-only-mode .requires-write-interactive,
body.read-only-mode .btn[data-requires-write="interactive"] {
  opacity: 0.6;
  cursor: not-allowed !important;
  pointer-events: auto; /* Allow click to show toast */
  border-style: dashed !important;
  border-color: #dc3545 !important;
}

body.read-only-mode .requires-write-interactive:hover,
body.read-only-mode .btn[data-requires-write="interactive"]:hover {
  opacity: 0.7;
  background-color: #f8d7da !important;
}

/* Lock icon badge for disabled buttons */
body.read-only-mode .requires-write::after,
body.read-only-mode [data-requires-write="true"]::after {
  content: "\F47A"; /* Bootstrap Icons lock icon */
  font-family: "bootstrap-icons";
  position: absolute;
  top: -5px;
  right: -5px;
  font-size: 0.7rem;
  background: #dc3545;
  color: white;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* For inline elements, simpler styling */
body.read-only-mode .text-requires-write {
  color: var(--muted) !important;
  text-decoration: line-through;
}

/* Toast for read-only action attempts */
.read-only-toast {
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #856404;
}

/* Hide elements completely in read-only mode */
body.read-only-mode .hide-read-only {
  display: none !important;
}

/* Show alternative content for read-only users */
.show-read-only {
  display: none !important;
}

body.read-only-mode .show-read-only {
  display: inline-block !important;
}

body.read-only-mode .show-read-only.d-block {
  display: block !important;
}

/* ========================================
   AUTOMATIC READ-ONLY BUTTON PROTECTION
   Styles for buttons blocked by JavaScript
   ======================================== */

/* Style for automatically detected write buttons */
body.read-only-mode .read-only-disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  position: relative;
  pointer-events: auto; /* Keep clickable to show toast */
}

body.read-only-mode .read-only-disabled:hover {
  opacity: 0.6 !important;
  background-color: #f8d7da !important;
  border-color: #dc3545 !important;
}

/* Lock icon added by JavaScript */
body.read-only-mode .read-only-lock {
  color: #dc3545;
  font-size: 0.8em;
}

/* Animation when button is blocked */
.read-only-blocked {
  animation: read-only-shake 0.3s ease-in-out;
}

@keyframes read-only-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* Special styling for HTMX elements in read-only mode */
body.read-only-mode [hx-post].read-only-disabled,
body.read-only-mode [hx-delete].read-only-disabled,
body.read-only-mode [hx-put].read-only-disabled,
body.read-only-mode [hx-patch].read-only-disabled {
  border: 2px dashed #dc3545 !important;
  background-color: #f8d7da !important;
}

/* Form submit buttons in read-only mode */
body.read-only-mode form[method="post"] button[type="submit"].read-only-disabled,
body.read-only-mode form[method="post"] input[type="submit"].read-only-disabled {
  background-color: #6c757d !important;
  border-color: #6c757d !important;
  color: white !important;
}

