:root {
    --bg-color: #F5F5F5;
    --panel-color: #E0E0E0;
    --text-color: #222222;
    --accent-primary: #4A90E2;
    --accent-secondary: #FF9500;
    --border-color: #333333;
    --input-bg: #f9f9f9;
    --error-color: #d32f2f;
    --success-color: #388e3c;
    --warning-color: #f57c00;
}

.colorblind-mode {
    --accent-primary: #000000;
    --accent-secondary: #8B4513;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.clac360-biocalc-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    padding: 20px;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    width: 100%;
    overflow-x: hidden;
}

@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
        gap: 15px;
    }
    
    .clac360-biocalc-container {
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 5px;
    }
    
    .panel {
        padding: 15px !important;
    }
    
    .button-row {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .csv-controls {
        flex-direction: column;
    }
    
    .input-row {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
    
    .chart-container {
        height: 300px !important;
    }
    
    .results-content {
        max-height: 400px !important;
    }
    
    .section-title {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px;
    }
    
    .title-text {
        font-size: 1.2rem;
    }
}

.panel {
    background-color: var(--panel-color);
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    width: 100%;
    overflow: hidden;
}

.section-title {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
}

.title-text {
    font-weight: 700;
    max-width: 100%;
    word-wrap: break-word;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--accent-primary);
    border-radius: 34px;
    transition: .4s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    border-radius: 50%;
    transition: .4s;
}

input:checked + .toggle-slider {
    background-color: var(--accent-secondary);
}

input:checked + .toggle-slider:before {
    transform: translateX(32px);
}

.method-selector {
    margin-bottom: 25px;
    width: 100%;
}

.method-dropdown, .submethod-dropdown {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    background-color: var(--input-bg);
    border-radius: 6px;
    color: var(--text-color);
    margin-bottom: 10px;
    cursor: pointer;
    transition: border-color 0.2s;
    max-width: 100%;
    box-sizing: border-box;
    /* Fix for dropdown text visibility */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 50px;
    display: flex;
    align-items: center;
    position: relative;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 20px;
    padding-right: 50px;
}

.method-dropdown:focus, .submethod-dropdown:focus,
.input-field:focus, .unit-select:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Ensure dropdown options are fully visible */
.method-dropdown option, .submethod-dropdown option {
    white-space: normal;
    word-wrap: break-word;
    max-width: 100%;
    padding: 8px;
    background-color: var(--input-bg);
    color: var(--text-color);
}

.input-group {
    margin-bottom: 20px;
    width: 100%;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
    width: 100%;
}

@media (max-width: 768px) {
    .input-row {
        grid-template-columns: 1fr;
    }
}

.input-field-container {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.input-label {
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-color);
    display: flex;
    justify-content: space-between;
    width: 100%;
}

.required-star {
    color: var(--error-color);
    font-size: 1.2rem;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    width: 100%;
    /* Fix for input field visibility */
    min-width: 0;
    overflow: visible;
    /* Adjusted ratio: input fields take more space, units less */
    flex-wrap: nowrap;
}

/* INPUT FIELD WIDTH INCREASED */
.input-field {
    flex: 3; /* Changed from flex: 1 to flex: 3 for wider input */
    padding: 12px;
    border: 2px solid var(--border-color);
    background-color: var(--input-bg);
    border-radius: 6px;
    font-size: 1rem;
    color: var(--text-color);
    transition: border-color 0.2s;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    /* Ensure text is fully visible */
    height: 50px;
    line-height: 1.5;
    overflow: visible;
    white-space: nowrap;
}

.input-field:focus {
    border-color: var(--accent-primary);
}

/* UNIT SELECT WIDTH REDUCED */
.unit-select {
    flex: 1; /* Reduced width - takes less space */
    padding: 12px;
    border: 2px solid var(--border-color);
    background-color: var(--input-bg);
    border-radius: 6px;
    font-size: 1rem;
    color: var(--text-color);
    min-width: 80px; /* Reduced from 100px */
    max-width: 120px; /* Added max-width constraint */
    cursor: pointer;
    box-sizing: border-box;
    /* Ensure unit select is fully visible */
    height: 50px;
    line-height: 1.5;
    overflow: visible;
    white-space: nowrap;
    /* Center text in unit select */
    text-align: center;
    text-align-last: center;
    -moz-text-align-last: center;
}

/* Unit select options styling */
.unit-select option {
    text-align: left;
    padding: 8px;
    background-color: var(--input-bg);
    color: var(--text-color);
}

@media (max-width: 480px) {
    .unit-select {
        min-width: 70px; /* Slightly smaller on mobile */
        font-size: 0.9rem;
        max-width: 100px;
    }
    
    .input-field {
        flex: 2.5; /* Adjust ratio for mobile */
    }
}

.button-row {
    display: flex;
    gap: 15px;
    margin-top: 25px;
    flex-wrap: wrap;
    width: 100%;
}

.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 50px;
    box-sizing: border-box;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .btn {
        padding: 12px 20px;
        font-size: 0.9rem;
        width: 100%;
    }
}

.btn-primary {
    background-color: var(--accent-primary);
    color: white;
}

.btn-primary:hover, .btn-primary:focus {
    background-color: #3a7bc8;
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.btn-secondary {
    background-color: var(--accent-secondary);
    color: white;
}

.btn-secondary:hover, .btn-secondary:focus {
    background-color: #e68900;
    outline: 2px solid var(--accent-secondary);
    outline-offset: 2px;
}

.btn-outline {
    background-color: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-color);
}

.btn-outline:hover, .btn-outline:focus {
    background-color: rgba(0, 0, 0, 0.05);
    outline: 2px solid var(--border-color);
    outline-offset: 2px;
}

.results-panel {
    grid-column: span 2;
    width: 100%;
    overflow: hidden;
}

@media (max-width: 1024px) {
    .results-panel {
        grid-column: span 1;
    }
}

.results-content {
    background-color: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    padding: 20px;
    margin-top: 20px;
    max-height: 500px;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    box-sizing: border-box;
}

.result-item {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

.result-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: var(--accent-primary);
    max-width: 100%;
}

.result-value {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 10px 0;
    color: var(--text-color);
    max-width: 100%;
    word-break: break-word;
}

@media (max-width: 480px) {
    .result-value {
        font-size: 1.5rem;
    }
}

.result-unit {
    font-size: 1rem;
    color: var(--text-color);
    opacity: 0.8;
}

.calculation-steps {
    background-color: rgba(255, 255, 255, 0.5);
    border-left: 4px solid var(--accent-primary);
    padding: 15px;
    margin: 15px 0;
    font-family: monospace;
    white-space: pre-wrap;
    border-radius: 0 6px 6px 0;
    font-size: 0.9rem;
    width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    overflow-x: hidden;
}

@media (max-width: 480px) {
    .calculation-steps {
        font-size: 0.85rem;
        padding: 10px;
    }
}

.dynamic-block {
    padding: 15px;
    margin: 15px 0;
    border-radius: 6px;
    width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

.dynamic-comment {
    background-color: rgba(74, 144, 226, 0.1);
    border-left: 4px solid var(--accent-primary);
}

.dynamic-analysis {
    background-color: rgba(255, 149, 0, 0.1);
    border-left: 4px solid var(--accent-secondary);
}

.dynamic-recommendation {
    background-color: rgba(0, 128, 0, 0.1);
    border-left: 4px solid var(--success-color);
}

.block-title {
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
}

.csv-section {
    margin-top: 30px;
    width: 100%;
}

.csv-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    width: 100%;
}

.csv-preview {
    background-color: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    padding: 15px;
    margin-top: 15px;
    max-height: 300px;
    overflow-y: auto;
    overflow-x: auto;
    font-size: 0.9rem;
    width: 100%;
}

.csv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    table-layout: auto;
    min-width: min-content;
}

.csv-table th, .csv-table td {
    border: 1px solid var(--border-color);
    padding: 8px;
    text-align: left;
    word-break: break-word;
    min-width: 100px;
}

.csv-table th {
    background-color: var(--panel-color);
    font-weight: 600;
}

.csv-table tr.error-row {
    background-color: rgba(211, 47, 47, 0.1);
}

.error-message {
    color: var(--error-color);
    font-weight: 500;
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 100%;
}

.success-message {
    color: var(--success-color);
    font-weight: 500;
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 100%;
}

.chart-container {
    height: 400px;
    margin-top: 20px;
    position: relative;
    width: 100%;
    overflow: hidden;
}

@media (max-width: 768px) {
    .chart-container {
        height: 350px;
    }
}

.trademark {
    position: fixed;
    bottom: 15px;
    right: 20px;
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.7;
    z-index: 100;
}

@media (max-width: 480px) {
    .trademark {
        position: static;
        text-align: center;
        margin-top: 20px;
    }
}

.version-info {
    position: fixed;
    bottom: 15px;
    left: 20px;
    font-size: 0.8rem;
    color: var(--text-color);
    opacity: 0.5;
    z-index: 100;
}

@media (max-width: 480px) {
    .version-info {
        position: static;
        text-align: center;
        margin-top: 10px;
    }
}

.hidden {
    display: none;
}

.loading-indicator {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.progress-bar {
    width: 100%;
    height: 10px;
    background-color: var(--input-bg);
    border-radius: 5px;
    margin: 15px 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--accent-primary);
    transition: width 0.3s ease;
}

.washout-warning {
    background-color: rgba(211, 47, 47, 0.1);
    border-left: 4px solid var(--error-color);
    padding: 15px;
    margin: 15px 0;
    border-radius: 0 6px 6px 0;
    width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

.icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.chart-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    width: 100%;
}

.chart-tab {
    padding: 8px 16px;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chart-tab.active {
    background-color: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.mobile-optimized {
    touch-action: manipulation;
}

input[type="number"] {
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Additional fixes for input visibility */
.input-wrapper::after {
    content: '';
    display: table;
    clear: both;
}

.input-field, .unit-select {
    box-shadow: none;
    -webkit-box-shadow: none;
    -moz-box-shadow: none;
}

.input-field:not(:focus), .unit-select:not(:focus) {
    border-color: var(--border-color);
}

/* Ensure grid items don't overflow */
.input-row > * {
    min-width: 0;
    overflow: visible;
}

/* Fix for dropdown in Firefox */
@-moz-document url-prefix() {
    .method-dropdown, .submethod-dropdown {
        text-indent: 0;
        padding-left: 16px;
    }
}