.fin-expenses-tree {
  --spacing: 30px;
  --radius: 10px;
  --line-color: #bdc3c7;
  --line-width: 2px;
  --hover-color: #f8f9fa;
  --parent-bg: #e8f4f8;
  
  margin: 20px;
  padding: 20px;
}

.fin-expenses-tree .tree-table {
  background-color: white;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.fin-expenses-tree .tree-header {
  display: flex;
  background-color: #2c3e50;
  color: white;
  padding: 15px 20px;
  font-weight: bold;
  border-bottom: 2px solid #34495e;
}

.fin-expenses-tree .tree-col-category {
  flex: 2;
  padding-right: 20px;
}

.fin-expenses-tree .tree-col-mapping {
  flex: 1;
  min-width: 200px;
}

.fin-expenses-tree .tree-body {
  padding: 20px;
}

/* Tree styling */
.fin-expenses-tree .tree {
  margin: 0;
  padding: 0;
  position: relative;
}

.fin-expenses-tree .tree ul {
  margin: 0;
  padding: 0;
  padding-left: var(--spacing);
  position: relative;
}

.fin-expenses-tree .tree li {
  margin: 0;
  padding: 0;
  list-style-type: none;
  position: relative;
  padding: 8px 0;
}

.fin-expenses-tree .tree-item-content {
  display: flex;
  padding: 12px 20px;
  background-color: white;
  border-radius: 4px;
  margin-left: calc(var(--spacing) / 2);
  transition: background-color 0.2s ease;
  position: relative;
  z-index: 2;
  gap: 20px;
}

.fin-expenses-tree .tree-item-content:hover {
  background-color: var(--hover-color);
}

.fin-expenses-tree .tree li:has(> ul) > .tree-item-content:not(.subaccount-item) {
  background-color: white;
  font-weight: bold;
}

.fin-expenses-tree .tree li:has(> ul) > .tree-item-content:hover {
  background-color: #d4edf9;
}

.fin-expenses-tree .tree-col-category {
  flex: 2;
  padding-right: 20px;
  display: flex;
  align-items: center;
}

.fin-expenses-tree .tree-col-mapping {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
}

.fin-expenses-tree .mapping-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-color: white;
  font-size: 0.9em;
  color: #2c3e50;
}

.fin-expenses-tree .mapping-select:focus {
  outline: none;
  border-color: #2c3e50;
  box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.2);
}

.mapping-select.value-changed {
  background-color: #e3f2fd !important;
  border-color: #2196f3 !important;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2) !important;
}

.mapping-select.value-changed:focus {
  background-color: #bbdefb !important;
  border-color: #1976d2 !important;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.3) !important;
}

.mapping-select {
  transition: all 0.3s ease;
}

/* Vertical line for nested lists */
.fin-expenses-tree .tree ul {
  border-left: var(--line-width) solid var(--line-color);
  margin-left: calc(var(--spacing) / 2);
}

/* Horizontal connector line */
.fin-expenses-tree .tree li::before {
  content: '';
  position: absolute;
  top: 50%;
  left: calc(var(--spacing) * -1);
  width: var(--spacing);
  height: 0;
  border-top: var(--line-width) solid var(--line-color);
}

/* Remove horizontal line for top-level items */
.fin-expenses-tree .tree > li::before {
  display: none;
}

/* Remove vertical line for last item in nested lists */
.fin-expenses-tree .tree ul li:last-child::after {
  content: '';
  position: absolute;
  top: 50%;
  left: calc(var(--spacing) * -1 - var(--line-width));
  height: 50%;
  width: var(--line-width);
  background: white;
  z-index: 1;
}

.fin-expenses-tree .category-name {
  color: #2c3e50;
}

.fin-expenses-tree .tree li:has(> ul) .category-name {
  color: #2c3e50;
}

@media (max-width: 768px) {
  .fin-expenses-tree {
    --spacing: 20px;
  }
  
  .fin-expenses-tree .tree-table {
    font-size: 0.9em;
  }
  
  .fin-expenses-tree .tree-header {
    padding: 12px 15px;
    flex-direction: column;
    gap: 10px;
  }
  
  .fin-expenses-tree .tree-item-content {
    padding: 8px 15px;
    flex-direction: column;
    gap: 10px;
  }
  
  .fin-expenses-tree .tree-col-category,
  .fin-expenses-tree .tree-col-mapping {
    flex: none;
    width: 100%;
    padding-right: 0;
  }
  
  .fin-expenses-tree .tree-col-mapping {
    min-width: auto;
  }
  
  .fin-expenses-tree .tree ul { 
    padding-left: var(--spacing);
    margin-left: calc(var(--spacing) / 2);
  }
  
  .fin-expenses-tree .tree ul ul { 
    padding-left: calc(var(--spacing) - 5px);
  }
  
  .fin-expenses-tree .tree ul ul ul { 
    padding-left: calc(var(--spacing) - 10px);
  }
  
  .fin-expenses-tree .tree li::before {
    left: calc(var(--spacing) * -1);
    width: var(--spacing);
  }
  
  .fin-expenses-tree .tree ul li:last-child::after {
    left: calc(var(--spacing) * -1 - var(--line-width));
  }
}

.fin-expenses-tree .tree-item-content {
  transition: all 0.2s ease;
}

.custom-farm-btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s ease;
  max-width: 140px;
  width: 100%;
  box-sizing: border-box;
}

.cancel-btn {
  background-color: #f8f9fa;
  color: #6c757d;
  border: 1px solid #6c757d;
}

.cancel-btn:hover {
  background-color: #dc3545;
  color: white;
  border-color: #dc3545;
  box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
}

.save-btn {
  background-color: #3498db;
  color: white;
  border: 1px solid #3498db;
}

.save-btn:hover {
  background-color: #2980b9;
  border-color: #2980b9;
  box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
}

.save-btn:active,
.save-btn:focus {
  background-color: #004085;
  border-color: #004085;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.5);
}
.form-actions {
  display: flex;
  justify-content: space-between; 
  align-items: center;
  margin-top: 20px;
  padding: 15px 0;
}

.cancel-btn {
  order: 1; 
}

.save-btn {
  order: 2;
}


@media (max-width: 480px) {
  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }
  
  .btn {
    max-width: none;
  }
}

.dept-mapping-section {
  margin-bottom: 30px;
}

.dept-mapping-table {
  background-color: white;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

.dept-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.dept-item {
  border-bottom: 1px solid #eee;
}

.dept-item:last-child {
  border-bottom: none;
}

.dept-item-content {
  display: flex;
  padding: 15px 20px;
  align-items: center;
}

.tree-col-dept {
  flex: 1;
  padding-right: 20px;
  font-weight: 500;
}

.tree-col-category {
  flex: 1;
  min-width: 250px;
}

.category-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-color: white;
  font-size: 0.9em;
}

.category-select:focus {
  outline: none;
  border-color: #2c3e50;
  box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.2);
}

.dept-mapping-section p {
  background-color: #e3f2fd;
  padding: 15px;
  border-radius: 4px;
  border-left: 4px solid #2196f3;
  margin-bottom: 20px;
}

.dept-mapping-table .tree-header {
  display: flex;
  background-color: #2c3e50;
  color: white;
  padding: 15px 20px;
  font-weight: bold;
  border-bottom: 2px solid #34495e;
}

@media (max-width: 768px) {
  .dept-item-content {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }
  
  .tree-col-dept,
  .tree-col-category {
    flex: none;
    width: 100%;
    padding-right: 0;
  }
  
  .category-select {
    min-width: auto;
  }
}
/* Department specific styles - NO horizontal lines and less padding */
.department-item {
  margin-left: 0;
  padding: 6px 15px !important; /* Less padding for departments */
}

.department-item::before {
  display: none !important; /* Remove horizontal line completely */
}

.department-item .tree-col-category {
  padding-left: 8px; /* Less padding for department text */
}

.department-name {
  font-style: italic;
  color: #6c757d !important;
  font-weight: normal !important;
  font-size: 0.95em; /* Slightly smaller font for departments */
}


/* Account level styles */
.account-item {
  padding: 12px 20px; /* Normal padding */
}

.account-name {
  font-weight: 700;
  color: #2c3e50;
}

/* Remove horizontal lines specifically for department items */
.tree li.department-item::before {
  display: none !important;
}

/* Adjust vertical lines for different levels */
.account-children {
  border-left: var(--line-width) solid var(--line-color);
  margin-left: calc(var(--spacing) / 2);
}

.department-children {
  border-left: var(--line-width) solid #d1d7dc; /* Lighter color for departments */
  margin-left: calc(var(--spacing) / 2);
}

/* Ensure proper spacing for department children */
.tree ul ul ul { /* Department level */
  padding-left: calc(var(--spacing) - 10px); /* Less indentation for departments */
}

/* Make department select dropdowns compact to match reduced padding */
.department-item .mapping-select {
  background-color: white;
  border: 1px solid #dee2e6;
  padding: 6px 10px; /* Compact dropdown for departments */
  font-size: 0.9em;
  height: 34px; /* Fixed height for consistency */
}

/* Adjust dropdown alignment for compact department items */
.department-item .tree-col-mapping {
  display: flex;
  align-items: center;
}

/* Remove any hover effects that might conflict with department styling */
.department-item:hover {
  background-color: #f8f9fa !important; /* Maintain consistent background on hover */
}

/* Ensure department items don't inherit bold styles */
.department-item .category-name {
  font-weight: normal !important;
}

/* Compact form for department level */
.department-item .tree-item-content {
  min-height: 40px;
  align-items: center;
}

/* Responsive adjustments for department items */
@media (max-width: 768px) {
  .department-item {
    padding: 5px 12px !important; /* Even more compact on mobile */
  }
  
  .department-item .mapping-select {
    padding: 4px 8px;
    font-size: 0.85em;
  }
  
  .department-name {
    font-size: 0.9em;
  }
}

.tree ul ul ul li::before {
  height: 0 !important;
  border: none !important;
}

.fin-expenses-tree .tree .department-children li,
.fin-expenses-tree .tree ul ul ul li {
  padding: 0px 0 !important;
}

.collapsible-section details {
  border: none; 
  border-radius: 8px;
  background-color: transparent; 
  box-shadow: none; 
  margin-bottom: 30px;
}

.collapsible-section summary {
  padding: 15px 20px;
  cursor: pointer;
  outline: none;
  font-weight: 600;
  background-color: transparent; 
  border-bottom: none; 
  border-radius: 8px; 
  display: flex;
  align-items: center; 
  justify-content: flex-start;
}

.collapsible-section summary::-webkit-details-marker {
  display: none;
}

.collapsible-section summary::before {
  content: ''; 
  margin-right: 0;
  transition: none;
}

.collapsible-section details[open] summary::before {
  content: ''; 
  transform: none;
}

.collapsible-section summary h3 {
  margin: 0;
  color: #2c3e50;
  display: inline-block;
  font-size: 1.1em; 
  position: relative;
  padding-right: 20px;
}

.collapsible-section summary h3::after {
  content: '\25B6'; 
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8em;
  color: #6c757d;
  transition: transform 0.2s;
}

.collapsible-section details[open] summary h3::after {
  content: '\25BC'; 
  transform: translateY(-50%) rotate(0deg);
}

.collapsible-section summary:hover h3,
.collapsible-section details[open] summary h3 {
  text-decoration: underline;
}

.collapsible-section details[open] summary {
  border-bottom: none; 
  border-radius: 8px; 
}

.collapsible-section .tree-table,
.collapsible-section .form-actions {
  padding: 20px;
  border-top: none;
}

.collapsible-section details[open] .tree-table {
  border-top: none; 
}