*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
    sans-serif;
  background: #fafafa;
  color: #2c3e50;
}

/* Tab content area - professional light background */
.ui.bottom.attached.tab.segment {
  background: #fafafa !important;
  border: none !important;
  box-shadow: none !important;
  padding: 1.5rem;
  padding-bottom: 6rem; /* Space for fixed footer */
}

@media (max-width: 860px) {
  .ui.bottom.attached.tab.segment {
    padding-top: 0.5rem !important;
  }
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid #e1e8ed;
  background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%) !important;
  color: #ffffff !important;
}

/* Override Semantic UI inverted menu styles for header */
.app-header.ui.inverted.menu {
  background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%) !important;
  background-color: transparent !important;
}

.app-header h1 {
  margin: 0;
  font-size: 1.8rem;
}

.app-header p {
  margin: 0.4rem 0 0;
  color: rgba(255, 255, 255, 0.9);
}

.app-main {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1rem 2rem;
  position: relative;
}

/* Mapping Container - New design inspired by screenshot */
.mapping-container {
  display: grid;
  grid-template-columns: 40% 20% 40%;
  width: 100%;
  margin-top: 2rem;
  margin-bottom: 5rem;
  position: relative;
  min-height: 400px;
  align-items: start;
}

.mapping-panel {
  background: #ffffff;
  border: 1px solid #e1e8ed;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Keep overflow hidden for panels */
  position: relative;
  z-index: 1; /* Below SVG */
}

.mapping-spacer {
  /* Spacer for the 20% gap in the middle */
}

.panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e1e8ed;
  background: #f8f9fa;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.panel-title-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.panel-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #2c3e50;
  white-space: nowrap;
}

.panel-search {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.6rem;
  border: 1px solid #d1d9e0;
  border-radius: 4px;
  font-size: 0.85rem;
  background: #ffffff;
  color: #2c3e50;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.panel-search:focus {
  border-color: #4a90e2;
  box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.panel-count {
  font-size: 0.85rem;
  color: #6b7280;
  font-weight: 500;
}

.panel-content {
  flex: 1;
  overflow: visible; /* No internal scroll, use page scroll instead */
  padding: 0.5rem;
  position: relative;
  z-index: 0;
}

.empty-state {
  padding: 3rem 1rem;
  text-align: center;
  color: #95a5a6;
  font-size: 0.9rem;
}

.field-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.field-item {
  display: flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border: 1px solid #e1e8ed;
  border-radius: 6px;
  background: #ffffff;
  transition: all 0.2s ease;
  position: relative;
  min-height: 45px;
  gap: 0.6rem;
  z-index: 1; /* Below SVG layer so lines are visible */
}

.field-item:hover {
  background: #f8f9fa;
  border-color: #4a90e2;
  box-shadow: 0 2px 4px rgba(74, 144, 226, 0.1);
}

.field-item.account-drop-active {
  background: #e8f4f8;
  border-color: #4a90e2;
  border-width: 2px;
}

.field-item.invoice-drop-active {
  background: #e8f4f8;
  border-color: #4a90e2;
  border-width: 2px;
}

.field-item.invoice-dragging,
.field-item.account-dragging {
  opacity: 0.5;
  border-style: dashed;
}

/* Drop zones for hide buttons */
#btn-hide-this-record.drop-active,
#btn-hide-all-with-name.drop-active {
  background-color: #ff9800 !important;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
  transition: all 0.2s ease;
}

#btn-hide-all-with-name.drop-active {
  background-color: #f44336 !important;
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

.field-item.draggable {
  cursor: grab;
}

.field-item.draggable:active {
  cursor: grabbing;
}

/* Field Connectors */
.field-connector {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #4a90e2;
  background: #ffffff;
  flex-shrink: 0;
  position: relative;
  z-index: 20; /* Always above lines (z-index: 10) */
  transition: all 0.2s ease;
}

.field-connector.linked {
  background: #4a90e2;
  border-color: #4a90e2;
}

.field-connector-right {
  margin-left: auto; /* Push to the right */
  flex-shrink: 0;
}

.field-connector-left {
  margin-right: 0.75rem;
  flex-shrink: 0;
}

.field-item:hover .field-connector:not(.linked) {
  border-color: #357abd;
  background: #e8f4f8;
}

.field-item:hover .field-connector.linked {
  background: #357abd;
  border-color: #357abd;
}

/* Field Content */
.field-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.field-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f4f8;
  border-radius: 6px;
  color: #4a90e2;
  flex-shrink: 0;
}

.field-icon i {
  margin: 0 !important;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.field-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  line-height: 1.2;
}

.field-name {
  font-weight: 500;
  color: #2c3e50;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.field-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.8rem;
  color: #6b7280;
  line-height: 1.2;
}

.field-amount-container {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.field-amount {
  font-weight: 600;
  color: #2c3e50;
  white-space: nowrap;
}

.field-date {
  color: #6b7280;
  font-size: 0.8rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.field-type {
  padding: 0.15rem 0.4rem;
  background: #e8f4f8;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #4a90e2;
}

.field-remaining {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  white-space: nowrap;
}

.field-remaining.matched {
  color: #27ae60;
  background: #d4edda;
}

.field-remaining.unmatched {
  color: #e74c3c;
  background: #f8d7da;
}

.field-filename {
  color: #6b7280;
  font-style: italic;
}

.field-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

.field-actions button {
  margin: 0;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
}

.will-not-link-btn {
  background: #f0f4f8 !important;
  color: #6b7280 !important;
  box-shadow: none !important;
}

.will-not-link-btn:hover {
  background: #e1e8ed !important;
}

.will-not-link-btn.orange {
  background: #fff4e6 !important;
  color: #d97706 !important;
}

.delete-btn {
  background: transparent !important;
  color: #e74c3c !important;
  padding: 0.35rem !important;
  box-shadow: none !important;
}

.delete-btn:hover {
  background: rgba(231, 76, 60, 0.1) !important;
}

.lists-container {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.5rem;
  width: 100%;
  margin-top: 2rem;
  margin-bottom: 5rem; /* Space for footer */
}

.list-block {
  min-width: 0;
}

@media (max-width: 860px) {
  /* Show mobile filter button on mobile */
  .mobile-filter-button {
    display: inline-flex !important;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #4a90e2;
    color: #ffffff;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
  }

  .mobile-filter-button:hover {
    background: #357abd;
  }

  .mobile-filter-button i {
    margin: 0 !important;
  }

  .lists-container {
    grid-template-columns: 1fr;
  }
  
  .mapping-container {
    grid-template-columns: 1fr;
  }
  
  .mapping-container .mapping-spacer {
    display: none;
  }
}

/* Mobile filter sheet - hidden on desktop by default */
.mobile-filter-sheet {
  display: none;
}

/* Hide mobile filter button on desktop */
.mobile-filter-button {
  display: none;
}

@media (max-width: 860px) {
  /* Mobile: Hide "Pilotage comptable..." text and reduce header height */
  /* Make header sticky on mobile */
  .app-header {
    padding: 0.75rem 1rem;
    position: sticky !important;
    top: 0 !important;
    z-index: 999 !important;
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }

  /* Mobile: Reduce spacing between header and content */
  .ui.container {
    margin-top: 0.25rem !important;
  }

  /* Remove margins and maximize width for all tab containers on mobile */
  [data-tab="dashboard"] > .ui.container,
  [data-tab="graph"] > .ui.container,
  [data-tab="config"] > .ui.container,
  [data-tab="admin"] > .ui.container {
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100% !important;
  }

  .ui.bottom.attached.tab.segment {
    padding: 0.5rem 1rem !important;
    padding-top: 0.5rem !important;
    padding-bottom: 6rem !important;
  }

  /* Mobile: Align title and filter button with panels on Rapprochements tab */
  /* Remove container padding for link tab to align with panels */
  [data-tab="link"] > .ui.container {
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100% !important;
  }

  [data-tab="link"] > .ui.container > div:first-child {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    margin-bottom: 0.75rem !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }

  [data-tab="link"] > .ui.container > div:first-child h3 {
    margin: 0 !important;
  }

  [data-tab="link"] > .ui.container > div:first-child .mobile-filter-button {
    margin: 0 !important;
    flex-shrink: 0;
  }

  [data-tab="link"] .mapping-container {
    margin-top: 0 !important;
  }

  /* Align panel-header padding on mobile to match title/filter alignment */
  [data-tab="link"] .panel-header {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  .app-header .ui.container > div:first-child > .item:not(.header) {
    display: none;
  }

  /* Mobile: Hide "Application made by..." text */
  .app-bottom-bar .bottom-info {
    display: none;
  }

  /* Mobile: Hide "Ajouter" buttons */
  #btn-add-account,
  #btn-add-invoice,
  #accouchement-add-btn {
    display: none !important;
  }

  /* Mobile: Hide desktop tab menu */
  .desktop-tab-menu {
    display: none !important;
  }

  /* Mobile: Hide vertical menus for config and admin, show dropdowns instead */
  .desktop-config-menu,
  .desktop-admin-menu {
    display: none !important;
  }

  .mobile-config-dropdown-container,
  .mobile-admin-dropdown-container {
    display: block !important;
    width: 100%;
    padding: 0;
    padding-bottom: 0.5rem;
  }

  .mobile-config-dropdown-container h3,
  .mobile-admin-dropdown-container h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 0.75rem 0;
    padding: 0 1rem;
  }

  .mobile-config-dropdown-container select,
  .mobile-admin-dropdown-container select {
    width: calc(100% - 2rem) !important;
    margin: 0 1rem !important;
    padding: 0.75rem 1rem !important;
    font-size: 1rem !important;
    border: 1px solid #d1d9e0 !important;
    border-radius: 0.5rem !important;
    background: #ffffff !important;
    color: #2c3e50 !important;
  }

  /* Mobile: Make config and admin content full width */
  [data-tab="config"] .ui.grid,
  [data-tab="admin"] .ui.grid {
    display: block !important;
    margin: 0 !important;
    width: 100% !important;
  }

  .config-content-column,
  .admin-content-column,
  [data-tab="config"] .twelve.wide.column,
  [data-tab="admin"] .twelve.wide.column {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Mobile: Show hamburger menu button */
  .mobile-menu-button {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    border: none !important;
    color: #ffffff !important;
    font-size: 1.5rem;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    z-index: 10;
    position: relative;
  }

  .mobile-menu-button:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
  }

  .mobile-menu-button:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
  }

  .mobile-menu-button i {
    margin: 0 !important;
  }

  /* Mobile: Filter button and bottom sheet for Rapprochements, Accouchements, Graphique, Rétrocession */
  /* Filter button - compact icon button */
  .mobile-filter-button {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #4a90e2;
    color: #ffffff;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
  }

  .mobile-filter-button:hover {
    background: #357abd;
  }

  .mobile-filter-button i {
    margin: 0 !important;
  }

  /* Hide filters on mobile - they'll be in the bottom sheet */
  .filters-container .ui.menu,
  [data-tab="accouchements"] .accouchement-filters,
  [data-tab="graph"] .ui.container .ui.menu:not(.pagination):not([id*="pagination"]),
  [data-tab="retrocession"] > .ui.container > .retro-menu {
    display: none !important;
  }

  /* Mobile Filter Bottom Sheet - show on mobile */
  .mobile-filter-sheet {
    display: block !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1001;
    pointer-events: none;
  }

  .mobile-filter-sheet.active {
    pointer-events: all;
  }

  .mobile-filter-sheet-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .mobile-filter-sheet.active .mobile-filter-sheet-overlay {
    opacity: 1;
  }

  .mobile-filter-sheet-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 85vh;
    background: #ffffff;
    border-radius: 1rem 1rem 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    transform: translateY(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .mobile-filter-sheet.active .mobile-filter-sheet-content {
    transform: translateY(0);
  }

  .mobile-filter-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e1e8ed;
    flex-shrink: 0;
  }

  .mobile-filter-sheet-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #2c3e50;
  }

  .mobile-filter-sheet-close {
    background: transparent;
    border: none;
    color: #6b7280;
    font-size: 1.5rem;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-filter-sheet-close:hover {
    background-color: #f3f4f6;
  }

  .mobile-filter-sheet-close i {
    margin: 0 !important;
  }

  .mobile-filter-sheet-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
    -webkit-overflow-scrolling: touch;
  }

  /* Filter content styling in bottom sheet */
  .mobile-filter-sheet-body .ui.menu,
  .mobile-filter-sheet-body .accouchement-filters.ui.menu,
  .mobile-filter-sheet-body .retro-menu.ui.menu,
  .mobile-filter-sheet-body .accouchement-filters,
  .mobile-filter-sheet-body .retro-menu {
    display: flex !important;
    flex-direction: column !important;
    gap: 1rem !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    margin: 0 !important;
  }

  .mobile-filter-sheet-body .ui.menu .item,
  .mobile-filter-sheet-body .accouchement-filters .item,
  .mobile-filter-sheet-body .retro-menu .item {
    width: 100% !important;
    padding: 0.75rem 0 !important;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .mobile-filter-sheet-body .ui.menu .item:last-child,
  .mobile-filter-sheet-body .accouchement-filters .item:last-child,
  .mobile-filter-sheet-body .retro-menu .item:last-child {
    border-bottom: none;
  }

  .mobile-filter-sheet-body .ui.menu .item label,
  .mobile-filter-sheet-body .accouchement-filters .item label,
  .mobile-filter-sheet-body .retro-menu .item label {
    width: 100%;
    margin-right: 0 !important;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #2c3e50;
  }

  .mobile-filter-sheet-body .ui.menu .item .ui.dropdown,
  .mobile-filter-sheet-body .accouchement-filters .ui.dropdown,
  .mobile-filter-sheet-body .accouchement-filters select,
  .mobile-filter-sheet-body .ui.menu .item select,
  .mobile-filter-sheet-body .retro-menu .ui.dropdown,
  .mobile-filter-sheet-body .retro-menu select,
  .mobile-filter-sheet-body .retro-menu .ui.input,
  .mobile-filter-sheet-body .ui.menu .item input[type="date"] {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
  }

  .mobile-filter-sheet-body .ui.menu .item.filter-toggle {
    padding: 1rem !important;
    border: 1px solid #e1e8ed;
    border-radius: 0.5rem;
    background: #f8f9fa;
  }

  .mobile-filter-sheet-body .ui.menu .item.filter-toggle.active {
    background: #e8f4f8;
    border-color: #4a90e2;
  }

  .mobile-filter-sheet-body .ui.menu .item.filter-toggle .filter-text {
    text-align: left;
    line-height: 1.5;
  }

  .mobile-filter-sheet-body .ui.menu .right.menu {
    margin-left: 0 !important;
    width: 100%;
    flex-direction: column;
  }

  .mobile-filter-sheet-body .retro-menu .item {
    min-height: auto !important;
    height: auto !important;
  }

  .mobile-filter-sheet-body .retro-menu .ui.input {
    width: 100% !important;
  }

  .mobile-filter-sheet-body .retro-menu .ui.input > input {
    height: 44px !important;
    min-height: 44px !important;
  }

  .mobile-filter-sheet-body .ui.menu .item .ui.checkbox {
    width: 100%;
  }

  .mobile-filter-sheet-body .ui.menu .item .ui.checkbox label {
    width: auto;
    margin-bottom: 0;
  }
}

/* Mobile Filter Bottom Sheet - hidden on desktop by default, shown on mobile (see @media query below) */

/* Mobile Sidebar Styles */
.mobile-menu-button {
  display: none;
}

.mobile-sidebar {
  display: none;
}

/* Mobile Filter Toggle - hidden by default, shown on mobile */
.mobile-filter-toggle {
  display: none;
}

/* Mobile dropdown containers - hidden by default, shown on mobile */
.mobile-config-dropdown-container,
.mobile-admin-dropdown-container {
  display: none;
}

@media (max-width: 860px) {
  .mobile-sidebar {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    pointer-events: none;
  }

  .mobile-sidebar.active {
    pointer-events: all;
  }

  .mobile-sidebar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .mobile-sidebar.active .mobile-sidebar-overlay {
    opacity: 1;
  }

  .mobile-sidebar-content {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: #ffffff;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }

  .mobile-sidebar.active .mobile-sidebar-content {
    transform: translateX(0);
  }

  .mobile-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e1e8ed;
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    color: #ffffff;
  }

  .mobile-sidebar-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
  }

  .mobile-sidebar-close {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 1.5rem;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-sidebar-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
  }

  .mobile-sidebar-close i {
    margin: 0 !important;
  }

  .mobile-sidebar-menu {
    flex: 1;
    padding: 0.5rem 0;
  }

  .mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    color: #2c3e50;
    text-decoration: none;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
    cursor: pointer;
  }

  .mobile-menu-item:hover {
    background-color: #f8f9fa;
  }

  .mobile-menu-item.active {
    background-color: #e8f4f8;
    color: #4a90e2;
    font-weight: 600;
    border-left: 3px solid #4a90e2;
  }

  .mobile-menu-item i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
  }

  .mobile-menu-item span {
    font-size: 1rem;
  }
}

.card {
  background: #ffffff;
  border-radius: 0.5rem;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid #e1e8ed;
}

.card h2 {
  margin-top: 0;
  margin-bottom: 0.9rem;
  font-size: 1.2rem;
  color: #2c3e50;
}

.filters-container {
  width: 100%;
  padding: 0.5rem 0;
  background: transparent;
  margin-bottom: 1rem;
}

.filters-container .ui.menu {
  margin: 0;
  border: 1px solid rgba(34, 36, 38, 0.15);
  box-shadow: 0 1px 2px 0 rgba(34, 36, 38, 0.15);
  background: #ffffff;
  border-radius: 0.28571429rem;
}

.filters-container .ui.menu .item {
  padding: 0.92857143em 1.14285714em;
  font-size: 1rem;
}

.filters-container .ui.menu .item.filter-toggle {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease;
}

.filters-container .ui.menu .item.filter-toggle:hover {
  background-color: rgba(0, 0, 0, 0.03);
}

.filters-container .ui.menu .item.filter-toggle.active {
  background-color: #e8e8e8;
  font-weight: 500;
}

/* Filter text with line breaks */
.filters-container .ui.menu .item.filter-toggle .filter-text {
  display: inline-block;
  line-height: 1.2;
  text-align: center;
}

/* Make date inputs fully clickable */
.date-input-clickable {
  cursor: pointer;
}

.date-input-clickable::-webkit-calendar-picker-indicator {
  cursor: pointer;
}

.filters-container .ui.menu .item label {
  font-size: 1rem;
  margin: 0;
  font-weight: 500;
  color: #2c3e50;
  margin-right: 0.5rem;
}

.filters-container .ui.menu .item .ui.dropdown {
  font-size: 1rem;
  min-width: 100px;
}

.filters-container .ui.menu .item input[type="date"] {
  font-size: 1rem;
  padding: 0.4rem;
  border: 1px solid rgba(34, 36, 38, 0.15);
  border-radius: 0.28571429rem;
}

.filters-container .ui.menu .right.menu {
  margin-left: auto;
}

.filters-container .ui.menu .right.menu .item .ui.button {
  margin: 0;
  font-size: 1rem;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.checkbox-label input[type='checkbox'] {
  margin: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.9rem;
}

label {
  font-size: 0.85rem;
  color: #5a6c7d;
}

input {
  padding: 0.45rem 0.6rem;
  border-radius: 0.5rem;
  border: 1px solid #d1d9e0;
  background: #ffffff;
  color: #2c3e50;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus {
  border-color: #4a90e2;
  box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
  background: #ffffff;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1.1rem;
  border-radius: 0.375rem;
  border: none;
  background: #4a90e2;
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.4rem;
  font-size: 0.9rem;
  box-shadow: 0 2px 4px rgba(74, 144, 226, 0.3);
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

button:hover {
  background: #357abd;
  box-shadow: 0 4px 8px rgba(74, 144, 226, 0.4);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(74, 144, 226, 0.3);
}

.message {
  min-height: 1.1rem;
  font-size: 0.8rem;
  margin: 0.4rem 0 0;
}

.message.error {
  color: #e74c3c;
}

.message.success {
  color: #27ae60;
}

.tabs {
  display: inline-flex;
  background: #020617;
  border-radius: 999px;
  padding: 0.15rem;
  border: 1px solid #1f2937;
  margin-bottom: 1rem;
}

.tab {
  border-radius: 999px;
  background: transparent;
  color: #9ca3af;
  padding: 0.25rem 0.9rem;
  font-size: 0.85rem;
  box-shadow: none;
  margin-top: 0;
}

.tab.active {
  background: linear-gradient(135deg, #38bdf8, #22c55e);
  color: #020617;
}

.muted {
  font-size: 0.85rem;
  color: #95a5a6;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.items-table th,
.items-table td {
  padding: 0.45rem 0.4rem;
  border-bottom: 1px solid #e1e8ed;
}

.items-table thead th {
  text-align: left;
  font-size: 0.8rem;
  color: #5a6c7d;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #f8f9fa;
}

.items-table tbody tr:hover {
  background: #f0f4f8;
}

.items-table td:last-child {
  text-align: right;
}

/* Admin table cell truncation for long names */
#admin-org-table td:first-child,
#admin-user-table td:first-child,
#admin-user-table td:nth-child(2),
#admin-user-table td:nth-child(4) {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#admin-org-table td:first-child strong,
#admin-user-table td:first-child strong,
#admin-user-table td:nth-child(2) {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Compact user table styling - same font size as other tables */
#admin-user-table {
  font-size: 1em;
}

#admin-user-table th,
#admin-user-table td {
  padding: 0.6em 0.5em !important;
}

#admin-user-table th:first-child,
#admin-user-table td:first-child {
  max-width: 150px;
}

#admin-user-table th:nth-child(2),
#admin-user-table td:nth-child(2) {
  max-width: 120px;
}

#admin-user-table th:nth-child(3),
#admin-user-table td:nth-child(3) {
  max-width: 100px;
}

#admin-user-table th:nth-child(4),
#admin-user-table td:nth-child(4) {
  max-width: 150px;
}

#admin-user-table th:nth-child(5),
#admin-user-table td:nth-child(5) {
  max-width: 90px;
  text-align: center;
}

#admin-user-table th:nth-child(6),
#admin-user-table td:nth-child(6) {
  max-width: 120px;
}

#admin-user-table th:nth-child(7),
#admin-user-table td:nth-child(7) {
  max-width: 140px;
  text-align: center;
}

#admin-user-table .ui.mini.button {
  padding: 0.4em 0.6em;
  font-size: 0.85em;
}

#admin-user-table .ui.tiny.label {
  font-size: 0.75em;
  padding: 0.3em 0.5em;
}

/* Organization files table truncation */
#org-detail-files-table {
  table-layout: fixed;
  width: 100%;
}

#org-detail-files-table .org-file-name {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#org-detail-files-table .org-file-path {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#org-detail-files-table .org-file-type {
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

#org-detail-files-table .org-file-size {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

.badge-amount {
  display: inline-flex;
  padding: 0.08rem 0.5rem;
  border-radius: 999px;
  background: #e8f4f8;
  color: #2c3e50;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.link-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.08rem 0.5rem;
  border-radius: 999px;
  background: #e8f4f8;
  color: #4a90e2;
  font-size: 0.75rem;
  margin-right: 0.2rem;
  font-weight: 500;
}

.hidden {
  display: none;
}

.app-footer {
  padding: 0.8rem 1.5rem 1.1rem;
  font-size: 0.8rem;
  color: #6b7280;
  text-align: center;
  border-top: 1px solid #1e293b;
  background: #020617;
}

.app-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem 1rem;
  font-size: 0.8rem;
  color: #95a5a6;
  border-top: 1px solid #e1e8ed;
  background: #ffffff;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
  z-index: 100;
}

.bottom-actions {
  display: flex;
  gap: 0.5rem;
}

.bottom-actions button {
  padding-inline: 1.1rem;
}

.invoice-selected {
  background: #e8f4f8;
}

.account-linked {
  border-left: 3px solid #4a90e2;
  background: linear-gradient(to right, rgba(74, 144, 226, 0.1), transparent);
  position: relative;
}

.link-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(74, 144, 226, 0.9);
  color: #ffffff;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 10;
  border-radius: 0.25rem;
}

.account-linked:hover .link-overlay {
  display: flex;
}

.invoice-dragging {
  outline: 2px dashed #4a90e2;
  outline-offset: 2px;
}

.account-drop-active {
  background: linear-gradient(to right, rgba(74, 144, 226, 0.15), transparent);
}

.link-count {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  color: #5a6c7d;
  margin-right: 0.4rem;
}

.link-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Allow drag and drop to pass through */
  overflow: visible;
  z-index: 10; /* Above panels (z-index: 1) and field-items (z-index: 1) */
  background: transparent; /* Ensure it's transparent */
}

.link-layer g {
  pointer-events: all; /* But allow clicking on the lines themselves */
}

/* ChatGPT Console */
#chatgpt-console {
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3) !important;
  z-index: 1001 !important; /* Above bottom bar */
}

#chatgpt-console-content {
  line-height: 1.6;
  max-height: 250px;
  overflow-y: auto;
}

#chatgpt-console-close {
  margin-left: auto;
  background: #3c3c3c !important;
  color: #d4d4d4 !important;
}

#chatgpt-console-close:hover {
  background: #4c4c4c !important;
}

/* Adjust bottom bar when console is visible */
#chatgpt-console:not([style*="display: none"]) ~ .app-bottom-bar {
  bottom: 300px;
}

/* View Modal Styles */
.view-field {
  padding: 0.5rem;
  background: #f8f9fa;
  border-radius: 4px;
  min-height: 1.5rem;
  color: #2c3e50;
}

.view-field.matched {
  background: #d4edda;
  color: #27ae60;
  font-weight: 600;
}

.view-field.unmatched {
  background: #f8d7da;
  color: #e74c3c;
  font-weight: 600;
}

#view-links-list .item {
  border-bottom: 1px solid #e1e8ed;
}

#view-links-list .item:last-child {
  border-bottom: none;
}

/* User Info Dropdown Menu */
#user-info-container {
  position: relative;
}

#user-info-dropdown-trigger {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

#user-info-dropdown-trigger:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

#user-info-dropdown-menu {
  display: none !important;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  z-index: 1000;
  min-width: 150px;
  background: #ffffff;
  border: 1px solid #e1e8ed;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

#user-info-dropdown-menu.show {
  display: block !important;
}

#user-info-dropdown-menu .item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  color: #2c3e50;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background-color 0.2s ease;
  border: none;
  border-radius: 0;
}

#user-info-dropdown-menu .item:hover {
  background-color: #f8f9fa;
}

#user-info-dropdown-menu .item i {
  margin: 0;
  color: #e74c3c;
}

/* Modal styles - using Semantic UI modal component */

/* Accouchement modal - override Semantic UI textarea height */
#accouchement-modal #acc-description,
#accouchement-modal #acc-commentaire {
  min-height: 4em !important;
  height: 4em !important;
  resize: vertical;
}

/* Step 1: Import Type Selection - Segment Style */
#step-content-1 .ui.placeholder.segment {
  min-height: 200px;
  padding: 2rem;
}

#step-content-1 .column {
  transition: all 0.3s ease;
  padding: 1.5rem;
  border-radius: 4px;
}

#step-content-1 .column:hover {
  background-color: #f8f9fa;
  transform: translateY(-2px);
}

#step-content-1 .ui.icon.header {
  margin-bottom: 1rem;
}

#step-content-1 .ui.icon.header i.icon {
  font-size: 3em;
  margin-bottom: 0.5rem;
}

#step-content-1 .ui.vertical.divider {
  font-size: 1.2em;
  font-weight: bold;
  color: #767676;
}

/* Invoice view modal - two column layout */
#view-invoice-layout.ui.two.column.grid {
  margin: 0 !important;
  gap: 1.5rem;
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  width: 100% !important;
}

#view-invoice-layout .column {
  padding: 0 !important;
  width: 100% !important;
  max-width: none !important;
}

#view-file-preview-column {
  position: sticky;
  top: 0;
  align-self: start;
}

/* Hide when explicitly set to none in inline style */
#view-file-preview-column[style*="display: none"] {
  display: none !important;
}

/* Only show when not hidden (for invoices) */
#view-file-preview-column:not([style*="display: none"]) {
  display: block;
}

#view-file-preview-field {
  display: block;
}

/* Hide field when parent column is hidden */
#view-file-preview-column[style*="display: none"] #view-file-preview-field {
  display: none !important;
}

#view-file-preview {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#view-file-preview img {
  max-width: 100%;
  max-height: 500px;
  object-fit: contain;
  border-radius: 4px;
}

#view-file-preview iframe {
  width: 100%;
  min-height: 400px;
  border-radius: 4px;
}

/* Ensure modal content uses full width */
#view-modal .content {
  width: 100% !important;
}

#view-modal-view-mode .ui.form {
  width: 100% !important;
}

/* Accouchement filters sizing */
.accouchement-filters .item {
  padding: 0.4rem 0.6rem;
}

.accouchement-filters label {
  font-weight: 500;
}

.accouchement-filters select.ui.dropdown {
  min-width: 90px;
  max-width: 150px;
}

.accouchement-filters .ui.selection.dropdown {
  min-width: 90px;
  max-width: 150px;
  width: fit-content;
}

.accouchement-filters select#accouchement-year-filter + .ui.selection.dropdown {
  width: 90px;
}

.accouchement-filters select#acc-zero-filter + .ui.selection.dropdown {
  width: 120px;
}

.accouchement-filters select#acc-practitioner-filter + .ui.selection.dropdown {
  width: 120px;
}

.accouchement-filters select#acc-type-filter + .ui.selection.dropdown {
  width: 150px;
}

.accouchement-filters select#acc-retro-filter + .ui.selection.dropdown {
  width: 120px;
}

.accouchement-filters select#acc-depassement-percu-filter + .ui.selection.dropdown {
  width: 140px;
}

/* Accouchements filters: keep a single line on desktop */
@media (min-width: 861px) {
  .accouchement-filters.ui.menu {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
    align-items: flex-end;
    overflow: visible;
  }

  .accouchement-filters.ui.menu > .item {
    margin: 0 !important;
    padding: 0.25rem 0.4rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
  }

  .accouchement-filters label {
    margin-right: 0 !important;
    display: block;
    font-size: 0.75rem;
    line-height: 1.05;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .accouchement-filters .ui.selection.dropdown {
    min-width: 80px;
    max-width: 120px;
    width: 110px;
  }

  .accouchement-filters select#accouchement-year-filter + .ui.selection.dropdown {
    width: 75px;
  }

  .accouchement-filters select#acc-zero-filter + .ui.selection.dropdown {
    width: 110px;
  }

  .accouchement-filters select#acc-practitioner-filter + .ui.selection.dropdown {
    width: 110px;
  }

  .accouchement-filters select#acc-type-filter + .ui.selection.dropdown {
    width: 110px;
  }

  .accouchement-filters select#acc-retro-filter + .ui.selection.dropdown {
    width: 95px;
  }

  .accouchement-filters select#acc-depassement-percu-filter + .ui.selection.dropdown {
    width: 120px;
  }

  .accouchement-filters select#acc-retro-id-filter + .ui.selection.dropdown {
    width: 90px;
  }

  /* Keep "Montants" dropdown text on one line */
  .accouchement-filters select#acc-zero-filter + .ui.selection.dropdown .text,
  .accouchement-filters select#acc-zero-filter + .ui.selection.dropdown .menu > .item {
    white-space: nowrap;
  }
}

/* Comment badge for accouchements */
.comment-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #eef3fb;
  border: 1px solid #d5e3f6;
  color: #1f78d1;
  cursor: help;
  line-height: 1;
}

.comment-badge i.icon {
  margin: 0 !important;
  color: inherit;
  line-height: 1 !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.depassement-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #eaf7ef;
  border: 1px solid #c6eed5;
  color: #1f9d55;
  cursor: help;
  line-height: 1;
}

.depassement-badge i.icon {
  margin: 0 !important;
  color: inherit;
  line-height: 1 !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.depassement-badge .label {
  display: none;
}

/* CIC import detail label truncation */
.cic-detail-label {
  max-width: none;
  width: 100%;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#cic-import-detail-modal table {
  table-layout: fixed;
}

#cic-import-detail-modal td:nth-child(1) {
  width: 110px;
}

#cic-import-detail-modal td:nth-child(3) {
  width: 120px;
}

#cic-import-detail-modal td:nth-child(4) {
  width: 90px;
}

.desc-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #f3f1ff;
  border: 1px solid #d9d2ff;
  color: #5a45d6;
  cursor: help;
  line-height: 1;
}

.desc-badge i.icon {
  margin: 0 !important;
  color: inherit;
  line-height: 1 !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.notes-icons {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Accouchements table: ellipsis for long patient names */
#accouchement-table td:first-child {
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobile: Optimize accouchements table layout */
@media (max-width: 860px) {
  /* Hide table header on mobile */
  #accouchement-table thead {
    display: none;
  }

  /* Transform table rows into compact cards */
  #accouchement-table {
    border: none;
    box-shadow: none;
    background: transparent;
    margin: 0;
  }

  #accouchement-table tbody {
    display: block;
    width: 100%;
  }
  
  #accouchement-table tbody tr {
    display: block;
    width: 100%;
  }
  
  #accouchement-table tbody tr {
    background: #ffffff;
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    position: relative;
  }

  #accouchement-table tbody td {
    display: block;
    width: 100%;
  }

  /* Patient name - left side, with space for date on right */
  #accouchement-table tbody tr td:nth-child(1) {
    display: block !important;
    font-weight: 600;
    font-size: 1.1rem;
    color: #2c3e50;
    padding: 0;
    padding-right: 5rem; /* Space for date */
    border: none;
    margin-bottom: 0.5rem;
    width: 100%;
  }

  /* Date - positioned absolutely in top right */
  #accouchement-table tbody tr td:nth-child(2) {
    position: absolute !important;
    top: 0.75rem;
    right: 0.75rem;
    font-size: 0.85rem;
    color: #6b7280;
    padding: 0;
    border: none;
    margin: 0;
    font-weight: 500;
    white-space: nowrap;
    display: block !important;
    width: auto !important;
  }

  /* Container for Praticien and Type - force them on same line */
  #accouchement-table tbody tr td:nth-child(3),
  #accouchement-table tbody tr td:nth-child(4) {
    display: inline-block !important;
    width: calc(50% - 0.75rem) !important;
    padding: 0.25rem 0;
    border: none;
    font-size: 0.9rem;
    vertical-align: top;
    box-sizing: border-box;
  }

  #accouchement-table tbody tr td:nth-child(3) {
    padding-right: 1.5rem;
  }

  #accouchement-table tbody tr td:nth-child(3)::before {
    content: 'Praticien:';
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  #accouchement-table tbody tr td:nth-child(4)::before {
    content: 'Type:';
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  /* Type content - force single line with ellipsis if too long */
  #accouchement-table tbody tr td:nth-child(4) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Three amounts on same line - using inline-block with calculated widths */
  #accouchement-table tbody tr td:nth-child(5),
  #accouchement-table tbody tr td:nth-child(6),
  #accouchement-table tbody tr td:nth-child(7) {
    display: inline-block !important;
    width: calc(33.333% - 0.5rem) !important;
    padding: 0.25rem 0;
    border: none;
    font-size: 0.9rem;
    vertical-align: top;
    box-sizing: border-box;
  }

  #accouchement-table tbody tr td:nth-child(5),
  #accouchement-table tbody tr td:nth-child(6) {
    padding-right: 0.75rem;
  }

  #accouchement-table tbody tr td:nth-child(5)::before {
    content: 'Sécu:';
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  #accouchement-table tbody tr td:nth-child(6)::before {
    content: 'Dépassement:';
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  #accouchement-table tbody tr td:nth-child(7)::before {
    content: 'Rétrocession:';
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }


  /* Notes and Actions container */
  #accouchement-table tbody tr td:nth-child(8),
  #accouchement-table tbody tr td:nth-child(9) {
    display: inline-block !important;
    border-top: 1px solid #e1e8ed;
    margin-top: 0.25rem;
    vertical-align: middle;
  }

  /* Notes cell */
  #accouchement-table tbody tr td:nth-child(8) {
    width: auto !important;
    padding: 0.5rem 0.75rem 0.5rem 0;
    text-align: left;
    margin-right: auto;
  }

  /* Actions cell - align to right using float */
  #accouchement-table tbody tr td:nth-child(9) {
    width: auto !important;
    padding: 0.5rem 0 0.5rem 0;
    border: none;
    float: right !important;
  }

  #accouchement-table tbody tr td:nth-child(9) > div {
    justify-content: flex-end;
    gap: 0.5rem;
  }

  #accouchement-table tbody tr td:nth-child(9) button {
    flex: 1 1 auto;
    min-width: 80px;
  }

  .depassement-badge {
    width: auto;
    padding: 0 8px;
    border-radius: 999px;
    gap: 6px;
  }

  .depassement-badge .label {
    display: inline;
    font-size: 0.75rem;
    font-weight: 600;
  }

  /* Hide empty state colspan styling on mobile */
  #accouchement-table tbody tr td[colspan] {
    padding: 1rem;
    text-align: center;
  }

  /* Optimize pagination on mobile */
  #accouchement-pagination {
    margin-top: 0.75rem !important;
    justify-content: center !important;
  }

  /* Reduce spacing in accouchements container - same as retrocession */
  [data-tab="accouchements"] > .ui.container {
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100% !important;
  }

  /* Align title and filter button with content on Accouchements tab */
  [data-tab="accouchements"] > .ui.container > div:first-child {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    margin-bottom: 0.75rem !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }

  [data-tab="accouchements"] > .ui.container > div:first-child h3 {
    margin: 0 !important;
  }

  [data-tab="accouchements"] > .ui.container > div:first-child .mobile-filter-button {
    margin: 0 !important;
    flex-shrink: 0;
  }

  /* Retrocession table - transform to cards on mobile */
  /* Reduce container padding to make cards wider */
  [data-tab="retrocession"] > .ui.container {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100% !important;
  }

  /* Hide validate button in filters on mobile */
  [data-tab="retrocession"] .desktop-retro-validate-btn,
  [data-tab="retrocession"] .retro-menu .right.menu {
    display: none !important;
  }

  /* Show validate button outside filters on mobile */
  [data-tab="retrocession"] .mobile-retro-validate-btn {
    display: block !important;
  }

  [data-tab="retrocession"] table.ui.celled.table {
    border: none;
    box-shadow: none;
    background: transparent;
  }

  [data-tab="retrocession"] table.ui.celled.table thead {
    display: none;
  }

  [data-tab="retrocession"] table.ui.celled.table tbody,
  [data-tab="retrocession"] table.ui.celled.table tbody tr,
  [data-tab="retrocession"] table.ui.celled.table tbody td {
    display: block;
    width: 100%;
  }

  [data-tab="retrocession"] table.ui.celled.table tbody tr {
    background: #ffffff;
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  }

  /* Praticien name - header */
  [data-tab="retrocession"] table.ui.celled.table tbody tr td:nth-child(1) {
    font-weight: 600;
    font-size: 1.1rem;
    color: #2c3e50;
    padding: 0;
    border: none;
    margin-bottom: 0.5rem;
  }

  /* Three amounts on same line */
  [data-tab="retrocession"] table.ui.celled.table tbody tr td:nth-child(2),
  [data-tab="retrocession"] table.ui.celled.table tbody tr td:nth-child(3),
  [data-tab="retrocession"] table.ui.celled.table tbody tr td:nth-child(4) {
    display: inline-block !important;
    width: calc(33.333% - 0.5rem) !important;
    padding: 0.25rem 0;
    border: none;
    font-size: 0.9rem;
    vertical-align: top;
    box-sizing: border-box;
  }

  [data-tab="retrocession"] table.ui.celled.table tbody tr td:nth-child(2),
  [data-tab="retrocession"] table.ui.celled.table tbody tr td:nth-child(3) {
    padding-right: 0.75rem;
  }

  [data-tab="retrocession"] table.ui.celled.table tbody tr td:nth-child(2)::before {
    content: 'Rétro due:';
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  [data-tab="retrocession"] table.ui.celled.table tbody tr td:nth-child(3)::before {
    content: 'Montant rétro:';
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  [data-tab="retrocession"] table.ui.celled.table tbody tr td:nth-child(4)::before {
    content: 'Différence:';
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  /* Total row - keep amounts on same line but remove labels */
  [data-tab="retrocession"] table.ui.celled.table tbody tr:has(td:first-child:contains("Total")) td,
  [data-tab="retrocession"] table.ui.celled.table tbody tr[style*="font-weight"] td {
    border-top: 1px solid #e1e8ed;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
  }

  [data-tab="retrocession"] table.ui.celled.table tbody tr[style*="font-weight"] td:nth-child(2)::before,
  [data-tab="retrocession"] table.ui.celled.table tbody tr[style*="font-weight"] td:nth-child(3)::before,
  [data-tab="retrocession"] table.ui.celled.table tbody tr[style*="font-weight"] td:nth-child(4)::before {
    display: none;
  }

  [data-tab="accouchements"] > .ui.container > h3 {
    margin-bottom: 0.75rem !important;
  }

  /* Mobile: Optimize all tables in config and admin sections */
  [data-tab="config"] .ui.table,
  [data-tab="admin"] .ui.table,
  [data-tab="config"] table,
  [data-tab="admin"] table,
  .config-content .ui.table,
  .admin-content .ui.table,
  .config-content table,
  .admin-content table {
    border: none;
    box-shadow: none;
    background: transparent;
    margin: 0;
  }

  [data-tab="config"] .ui.table thead,
  [data-tab="admin"] .ui.table thead,
  .config-content .ui.table thead,
  .admin-content .ui.table thead {
    display: none;
  }

  [data-tab="config"] .ui.table tbody,
  [data-tab="admin"] .ui.table tbody,
  .config-content .ui.table tbody,
  .admin-content .ui.table tbody,
  [data-tab="config"] table tbody,
  [data-tab="admin"] table tbody,
  .config-content table tbody,
  .admin-content table tbody {
    display: block;
  }

  [data-tab="config"] .ui.table tbody tr,
  [data-tab="admin"] .ui.table tbody tr,
  .config-content .ui.table tbody tr,
  .admin-content .ui.table tbody tr,
  [data-tab="config"] table tbody tr,
  [data-tab="admin"] table tbody tr,
  .config-content table tbody tr,
  .admin-content table tbody tr {
    display: block;
    background: #ffffff;
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  }

  [data-tab="config"] .ui.table tbody tr td,
  [data-tab="admin"] .ui.table tbody tr td,
  .config-content .ui.table tbody tr td,
  .admin-content .ui.table tbody tr td,
  [data-tab="config"] table tbody tr td,
  [data-tab="admin"] table tbody tr td,
  .config-content table tbody tr td,
  .admin-content table tbody tr td {
    display: block;
    width: 100% !important;
    padding: 0.5rem 0;
    border: none !important;
    text-align: left !important;
    border-top: 1px solid #f0f0f0;
  }

  [data-tab="config"] .ui.table tbody tr td:first-child,
  [data-tab="admin"] .ui.table tbody tr td:first-child,
  .config-content .ui.table tbody tr td:first-child,
  .admin-content .ui.table tbody tr td:first-child,
  [data-tab="config"] table tbody tr td:first-child,
  [data-tab="admin"] table tbody tr td:first-child,
  .config-content table tbody tr td:first-child,
  .admin-content table tbody tr td:first-child {
    border-top: none;
    padding-top: 0;
  }

  /* Show labels if data-label attribute exists */
  [data-tab="config"] .ui.table tbody tr td[data-label]:before,
  [data-tab="admin"] .ui.table tbody tr td[data-label]:before,
  .config-content .ui.table tbody tr td[data-label]:before,
  .admin-content .ui.table tbody tr td[data-label]:before,
  [data-tab="config"] table tbody tr td[data-label]:before,
  [data-tab="admin"] table tbody tr td[data-label]:before,
  .config-content table tbody tr td[data-label]:before,
  .admin-content table tbody tr td[data-label]:before {
    content: attr(data-label) ": ";
    font-weight: 600;
    font-size: 0.75rem;
    color: #6b7280;
    display: inline;
    margin-right: 0.5rem;
  }

  /* Hide empty colspan cells */
  [data-tab="config"] .ui.table tbody tr td[colspan],
  [data-tab="admin"] .ui.table tbody tr td[colspan],
  .config-content .ui.table tbody tr td[colspan],
  .admin-content .ui.table tbody tr td[colspan],
  [data-tab="config"] table tbody tr td[colspan],
  [data-tab="admin"] table tbody tr td[colspan],
  .config-content table tbody tr td[colspan],
  .admin-content table tbody tr td[colspan] {
    text-align: center;
    padding: 1rem;
    border: none !important;
  }

  [data-tab="config"] .ui.table tbody tr td[colspan]:before,
  [data-tab="admin"] .ui.table tbody tr td[colspan]:before,
  .config-content .ui.table tbody tr td[colspan]:before,
  .admin-content .ui.table tbody tr td[colspan]:before,
  [data-tab="config"] table tbody tr td[colspan]:before,
  [data-tab="admin"] table tbody tr td[colspan]:before,
  .config-content table tbody tr td[colspan]:before,
  .admin-content table tbody tr td[colspan]:before {
    display: none;
  }

  /* Special handling for action columns - align buttons */
  [data-tab="config"] .ui.table tbody tr td button,
  [data-tab="admin"] .ui.table tbody tr td button,
  .config-content .ui.table tbody tr td button,
  .admin-content .ui.table tbody tr td button {
    margin-top: 0.5rem;
    margin-right: 0.5rem;
    margin-bottom: 0;
  }
}

#acc-retro-lock-info {
  padding: 0.6rem 0.75rem;
  margin-top: 0.5rem;
}

.accouchement-filters #accouchement-year-filter {
  width: 90px;
}

.accouchement-filters #acc-zero-filter {
  width: 120px;
}

.accouchement-filters #acc-practitioner-filter {
  width: 120px;
}

.accouchement-filters #acc-type-filter {
  width: 150px;
}

.accouchement-filters #acc-retro-filter {
  width: 120px;
}

.accouchement-filters #acc-retro-id-filter {
  width: 110px;
}

/* Mobile Floating Action Button */
.mobile-fab {
  display: none;
}

@media (max-width: 860px) {
  .mobile-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 6rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    background: #4a90e2;
    color: #ffffff;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4);
    cursor: pointer;
    z-index: 998;
    transition: all 0.3s ease;
  }

  .mobile-fab:hover {
    background: #357abd;
    box-shadow: 0 6px 16px rgba(74, 144, 226, 0.5);
    transform: translateY(-2px);
  }

  .mobile-fab:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.4);
  }

  .mobile-fab .icon {
    margin: 0 !important;
    font-size: 1.5rem;
  }

  /* Accouchement modal textarea height already set globally, but ensure it applies on mobile too */
}
