.bone-calculator-container.advanced-calculator {
  max-width: 100%;
  margin: 0 auto;
  font-family: Arial, sans-serif;
}

.advanced-calculator .calculator-info {
  margin-bottom: 1.5em;
  padding: 1em;
  background-color: #f9f9f9;
  border: 1px solid #eee;
  border-radius: 4px;
}
.advanced-calculator .calculator-info h3 {
  margin-top: 0;
}

.advanced-calculator .advanced-calculator-form {
  padding: 1em;
  border: 1px solid #ddd;
  margin-bottom: 1.5em;
  border-radius: 4px;
}

.advanced-calculator table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
}

.advanced-calculator table th,
.advanced-calculator table td {
  padding: 0.5em;
  text-align: left; /* Default to left, center specific headers/cells if needed */
}

.advanced-calculator input[type="number"],
.advanced-calculator input[type="text"] { /* Keep text for backward compatibility if needed */
  width: 100%; /* Make inputs responsive by default */
  padding: 0.5625rem 0.25rem;
  border: 1px solid #ccc;
  border-radius: 0;
  background-color: #fff;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
  color: rgba(0, 0, 0, 0.75);
  font-family: inherit;
  font-size: 0.9em;
  /* height: 2.3125rem; */ /* Let padding define height */
  margin: 0; /* Inputs inside table cells shouldn't have bottom margin */
  box-sizing: border-box;
  transition: border-color 0.15s linear, background 0.15s linear;
  -moz-appearance: textfield; /* Hide spinners in Firefox */
}
.advanced-calculator input[type="number"]::-webkit-outer-spin-button,
.advanced-calculator input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}


.advanced-calculator input[type="submit"].calculate-button-adv {
  direction: ltr;
  box-sizing: border-box;
  font: inherit;
  margin: 0 0 1em 0; /* Add bottom margin before table */
  cursor: pointer;
  -webkit-appearance: none;
  border-radius: 0;
  line-height: 1;
  display: inline-block;
  font-family: var(--main-font, Arial, sans-serif); /* Provide fallback for --main-font */
  text-transform: uppercase;
  padding: 1em !important;
  background: #086993;
  border: none !important;
  color: #fff !important;
  min-width: 180px; /* Min width for button */
}
.advanced-calculator .advanced-calculator-form table + input[type="submit"].calculate-button-adv {
  margin-top: 1em; /* Add top margin if button is after table */
}


.advanced-calculator .center { /* For tables/elements needing centering */
  margin-left: auto;
  margin-right: auto;
}

.advanced-calculator .calculator-footer-adv {
  margin-top: 2em;
  padding-top: 1em;
  border-top: 1px solid #eee;
  font-style: italic;
  text-align: center;
  font-size: 0.9em;
}

/* Input Table Specific Styles */
.advanced-calculator table#calculator.calculator-input-table-adv {
  border: solid 1px #ddd;
}
.advanced-calculator table#calculator.calculator-input-table-adv th {
  background: #3c6991;
  color: #fff;
  text-align: center;
}

/* Alternating row colors for input table */
.advanced-calculator table#calculator.calculator-input-table-adv tr.even {
  background: #f9f9f9;
}
/* Fallback if class is not applied, for modern browsers */
.advanced-calculator table#calculator.calculator-input-table-adv tbody tr:nth-of-type(even) {
  background-color: #f9f9f9;
}


.advanced-calculator table#calculator.calculator-input-table-adv td {
  /* padding: 0.5625rem 0.25rem; */ /* Already general table td */
  /* text-align: left; */ /* Default */
  position: relative; /* Needed for absolute positioning of the tooltip within the cell */
}
.advanced-calculator table#calculator.calculator-input-table-adv td:first-child { /* Patient number column */
  text-align: center;
  font-weight: bold;
}

/* Styles for input validation tooltips */
.decimal-tooltip {
  position: absolute;
  bottom: calc(100% + 5px); /* Position above the input field with a 5px gap */
  left: 50%;
  transform: translateX(-50%);
  background-color: #333; /* Dark background */
  color: #fff; /* Light text */
  padding: 6px 10px; /* Padding */
  border-radius: 4px; /* Rounded corners */
  font-size: 0.875em; /* Slightly smaller than base font */
  z-index: 1000; /* Ensure it's on top of other elements */
  white-space: nowrap; /* Prevent text from wrapping */
  box-shadow: 0 2px 4px rgba(0,0,0,0.2); /* Subtle shadow */
  opacity: 0;
  visibility: hidden;
  /* Fade out: opacity transition, then hide. Fade in: show, then opacity transition */
  transition: opacity 0.2s ease-in-out, visibility 0s linear 0.2s; 
  pointer-events: none; /* Tooltip should not be interactive */
}

.decimal-tooltip.visible {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s, 0s; /* Apply visibility transition immediately when becoming visible */
}

/* Ensure input fields don't get hidden by tooltip if cell padding is small */
.advanced-calculator table#calculator.calculator-input-table-adv td input[type="number"] {
    position: relative; 
    z-index: 1; 
}


/* Result Tables Styling */
.advanced-calculator .results-section-adv {
    margin-top: 2em;
    padding-top: 1em;
}
.advanced-calculator .results-section-adv h3,
.advanced-calculator .results-section-adv h5 {
    color: #333;
}
.advanced-calculator table.data-table-adv {
  border:1px solid black;
}

.advanced-calculator table.data-table-adv tbody tr:nth-child(even){
  background: #F9F9F9;
}
.advanced-calculator table.lsc-table-adv {
  background: #FFFF00; /* Lighter yellow */
  border:1px solid black;
}

.advanced-calculator table.lsc-table-adv tbody tr:nth-child(even) {
  background: #F9F9F9; 
}

.advanced-calculator .results-section-adv table th {
    background-color: #f0f0f0;
    text-align: center;
}
.advanced-calculator .results-section-adv table td {
    text-align: center; /* Center data in results tables */
}
.advanced-calculator .results-section-adv table td:first-child { /* First column usually a label */
    text-align: left;
    font-weight: normal;
}


.advanced-calculator .notice.iscd-calc-error {
    background-color: #f8d7da;
    color: #721c24;
    padding: .75rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid #f5c6cb;
    border-radius: .25rem;
}

/* Hide mobile-specific calculation rows by default */
.mobile-calc-results-row {
    display: none;
}


/* --- MOBILE OPTIMIZATIONS for Advanced Calculator Input Table --- */
@media (max-width: 768px) {
    .advanced-calculator table#calculator.calculator-input-table-adv thead {
        display: none; /* Hide traditional table header on mobile */
    }

    .advanced-calculator table#calculator.calculator-input-table-adv tr.patient-data-row-adv {
        display: block;
        border-bottom: none; /* Will be handled by mobile-calc-results-cell */
        margin-bottom: 0;
    }

    .advanced-calculator table#calculator.calculator-input-table-adv td {
        display: block;
        text-align: right; /* Align input/value to the right */
        padding-left: 45%; /* Make space for the label */
        position: relative; /* Still needed for ::before and tooltips */
        box-sizing: border-box;
        min-height: 3em; 
        padding-top: 0.85em;
        padding-bottom: 0.85em;
        border-bottom: 1px dotted #eee; /* Light separator between fields */
    }
    .advanced-calculator table#calculator.calculator-input-table-adv tr.patient-data-row-adv td:last-child {
        border-bottom: none; /* Last input field in the stack doesn't need bottom border */
    }


    .advanced-calculator table#calculator.calculator-input-table-adv td::before {
        content: attr(data-label); /* Display the label */
        position: absolute;
        left: 0.75em; 
        width: 40%; 
        padding-right: 0.5em; 
        font-weight: bold;
        text-align: left;
        white-space: nowrap;
    }
    
    .advanced-calculator table#calculator.calculator-input-table-adv td input[type="number"] {
        width: 100%; 
        margin: 0; 
    }

    /* Hide desktop-specific calculation columns and their headers */
    .desktop-calc-col-header,
    .advanced-calculator table#calculator.calculator-input-table-adv td.desktop-calc-col {
        display: none !important;
    }

    /* Style for the mobile-specific calculation results row */
    tr.mobile-calc-results-row {
        display: block; /* Show this row on mobile */
    }

    td.mobile-calc-results-cell {
        display: block; 
        width: 100%;
        padding: 0.5em 0; /* Padding for the cell containing calc items */
        /* border-top: 1px solid #ccc; Separator from inputs */
        border-bottom: 2px solid #086993; /* Strong separator after all patient data */
        margin-bottom: 1em; /* Space before next patient block */
    }
    td.mobile-calc-results-cell::before {
        display:none; /* No label for this container cell */
    }
	
	.mobile-calc-results-cell {
		padding-left: 0 !important;
		background: white;
	}
    
    .mobile-calc-item {
        display: block;
        text-align: left;    
        padding-left: 45%;   
        position: relative;
        box-sizing: border-box;
        min-height: 3em;    
        padding-top: 0.85em;  
        padding-bottom: 0.85em;
        border-bottom: 1px dotted #eee;
    }
    .mobile-calc-item:last-child {
        border-bottom: none;
    }

    .mobile-calc-item::before {
        content: attr(data-calc-label); 
        position: absolute;
        left: 0.75em;          
        width: 40%;          
        padding-right: 0.5em; 
        font-weight: bold;
        text-align: left;
        white-space: nowrap;
    }

    .mobile-calc-item strong {
        display: inline-block; 
        padding-right: 0.75em; 
        font-weight: bold;
    }

    /* Make submit button full width on small screens */
    .advanced-calculator .advanced-calculator-form input[type="submit"].calculate-button-adv {
        width: 100%;
        margin-top: 1em; 
    }

    /* Responsive adjustments for summary result tables if needed */
    .advanced-calculator .results-section-adv table td,
    .advanced-calculator .results-section-adv table th {
        font-size: 0.9em; /* Slightly smaller font for dense tables */
    }

    /* Mobile tooltip adjustments */
    .decimal-tooltip {
        font-size: 0.8em; /* Slightly smaller on mobile */
        /* If input fields are very close to the top of their TD block in mobile,
           the tooltip might need minor positional adjustment.
           However, `bottom: calc(100% + 5px)` should generally work well. */
    }
}

.advanced-calculator input[type="number"][data-is-invalid="true"] {
    /* You can use this selector if you prefer class-based styling for the border */
    /* border: 1px solid red !important; */ 
    /* background-color: #fff0f0; */ /* Optional: light red background */
}
.decimal-tooltip {
    /* Basic styling, adjust as needed */
    position: absolute;
    background-color: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.9em;
    z-index: 100;
    display: none; /* Hidden by default */
    margin-left: 5px; /* Adjust positioning */
}
.decimal-tooltip.visible {
    display: inline-block;
}