body {
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
    background-color: #f0f2f5;
}

.main {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    width: 80%;
    /* max-width: 600px; */
}

.container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.editable-div {
    border: 1px solid #ccc;
    padding: 10px;
    min-height: 36px;
    line-height: 36px;
    margin: 0;
    border-radius: 4px;
    outline: none;
    white-space: pre-wrap;
    overflow-x: auto;
}

.editable-div:focus {
    border-color: #0000ff;
}

.controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.search-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    max-width: 400px;
}

.search-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
}

.search-input:focus {
    border-color: #007bff;
}

.clear-search-button {
    padding: 0.5rem;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

.clear-search-button:hover {
    background-color: #545b62;
}

.search-info {
    margin-bottom: 1rem;
    padding: 0.5rem;
    background-color: #e9ecef;
    border-radius: 4px;
    font-size: 14px;
    color: #6c757d;
}

.search-info.show {
    display: block !important;
}

button {
    padding: 0.5rem 1rem;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    height: 38px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button:hover {
    background-color: #0056b3;
}

.sp_label {
    display: inline-flex;
    align-items: center;
    padding: 0px 10px;
    background-color: #007bff;
    color: white;
    border-radius: 3px;
    user-select: none;
    margin-right: 8px;
    font-weight: bold;
    vertical-align: middle;
    height: 36px;
    line-height: 36px;
}

.sp_variable {
    display: inline-flex;
    align-items: center;
    border-radius: 3px;
    user-select: none;
    margin-right: 8px;
    font-size: 14px;
    vertical-align: middle;
    overflow: hidden;
    height: 36px;
    line-height: 36px;
}

.sp_variable .name {
    background-color: #00a152;
    color: white;
    padding: 3px 10px;
    display: flex;
    align-items: center;
    font-weight: bold;
    height: 100%;
}

.sp_variable .value {
    background-color: #666666;
    color: white;
    padding: 3px 10px;
    display: flex;
    align-items: center;
    font-weight: bold;
    height: 100%;
}

.sp_label + br + text,
.sp_label + text {
    margin-left: 8px;
}

.editable-div > text:first-child {
    margin-left: 0;
}

.input-area {
    display: inline-block;
    min-width: 10px;
    padding: 5px;
    outline: none;
    margin-left: 4px;
}

.sp_formula {
    display: inline-flex;
    align-items: center;
    border-radius: 3px;
    user-select: none;
    margin-right: 8px;
    font-size: 14px;
    vertical-align: middle;
    overflow: hidden;
}

.sp_formula .name {
    background-color: #f59e42;
    color: white;
    padding: 0px 10px;
    display: flex;
    align-items: center;
    font-weight: bold;
    height: 100%;
}

.sp_formula .value {
    background-color: #666666;
    color: white;
    padding: 0px 10px;
    display: flex;
    align-items: center;
    font-weight: bold;
    height: 100%;
}

/* Total formula styling - special styling for formulas with #T prefix */
.sp_formula[data-type="total"] .name {
    background-color: #ff9800;
    color: white;
    padding: 0px 10px;
    display: flex;
    align-items: center;
    font-weight: bold;
    height: 100%;
}

.sp_formula[data-type="total"] .value {
    background-color: #d84315;
    color: white;
    padding: 0px 10px;
    display: flex;
    align-items: center;
    font-weight: bold;
    height: 100%;
}

.sp_formula[data-type="total"]:hover .name {
    background-color: #f57c00;
}

.sp_formula[data-type="total"]:hover .value {
    background-color: #bf360c;
}

.sp_material {
    display: inline-flex;
    align-items: center;
    border-radius: 3px;
    user-select: none;
    margin-right: 8px;
    font-size: 14px;
    vertical-align: middle;
    overflow: hidden;
    height: 36px;
    line-height: 36px;
}

.sp_material .name {
    background-color: #ff4444;
    color: white;
    padding: 3px 10px;
    display: flex;
    align-items: center;
    font-weight: bold;
    height: 100%;
}

.sp_material .value {
    background-color: #666666;
    color: white;
    padding: 3px 10px;
    display: flex;
    align-items: center;
    font-weight: bold;
    height: 100%;
}

.sp_opc {
    display: inline-flex;
    align-items: center;
    border-radius: 3px;
    user-select: none;
    margin-right: 8px;
    font-size: 14px;
    vertical-align: middle;
    overflow: hidden;
    height: 36px;
    line-height: 36px;
}

.sp_opc .name {
    background-color: #9c27b0;
    color: white;
    padding: 3px 10px;
    display: flex;
    align-items: center;
    font-weight: bold;
    height: 100%;
}

.sp_opc .value {
    background-color: #666666;
    color: white;
    padding: 3px 10px;
    display: flex;
    align-items: center;
    font-weight: bold;
    height: 100%;
}

.formula-input {
    margin-bottom: 1rem;
    width: 100%;
    box-sizing: border-box;
}

.formula-name-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
    background-color: #fff;
}

.formula-name-input:focus {
    border-color: #007bff;
}

.formula-name-input::placeholder {
    color: #999;
}

.back-button {
    background-color: #6c757d;
    margin-left: auto;
}

.back-button:hover {
    background-color: #5a6268;
}

.generate-report-button {
    background-color: #17a2b8;
    margin-top: 20px;
    width: 100%;
    padding: 10px;
    font-size: 16px;
}

.generate-report-button:hover {
    background-color: #138496;
}

.report-section {
    display: none;
    margin-top: 30px;
    padding: 20px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.report-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #eee;
}

.report-header h1 {
    color: #333;
    margin-bottom: 10px;
}

.report-header h2 {
    color: #666;
    font-size: 1.5em;
}

.report-content {
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 4px;
    min-height: 100px;
}

.report-footer {
    margin-top: 30px;
    text-align: right;
    color: #666;
    font-size: 0.9em;
    padding-top: 20px;
    border-top: 2px solid #eee;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background-color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.report-table th,
.report-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
    white-space: nowrap;
}

.report-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.report-table tr:hover {
    background-color: #f5f5f5;
}

.report-table td:nth-child(3) {
    text-align: right;
    padding-right: 20px;
}

.report-table th:nth-child(3) {
    text-align: right;
    padding-right: 20px;
}

.report-table {
    table-layout: auto;
}

.report-table th,
.report-table td {
    width: auto;
    min-width: 100px;
}

.report-table th:nth-child(1),
.report-table td:nth-child(1) {
    width: 60%;
}

.report-table th:nth-child(2),
.report-table td:nth-child(2) {
    width: 10%;
}

.report-table th:nth-child(3),
.report-table td:nth-child(3) {
    width: 20%;
}

.report-table th:nth-child(4),
.report-table td:nth-child(4) {
    width: 10%;
}

.line-content {
    white-space: pre-wrap;
    word-break: break-word;
}

.variable-input {
    width: 80px;
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    margin: 0 4px;
    vertical-align: middle;
}

.variable-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.variable-input::-webkit-inner-spin-button,
.variable-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.search-container {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
}

.search-input {
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 300px;
    margin-right: 10px;
}

.search-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    gap: 10px;
}

.pagination button {
    padding: 8px 16px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.pagination button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.pagination button:hover:not(:disabled) {
    background-color: #0056b3;
}

#pageInfo {
    font-size: 14px;
    color: #666;
}

/* Input Section Styles */
.input-section {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    background-color: #f5f5f5;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
}

.input-group {
    flex: 1 1 calc(20% - 15px);  /* 5 fields in a row */
    min-width: 150px;
    max-width: calc(20% - 15px);
    box-sizing: border-box;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.input-group input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.input-group input:focus {
    border-color: #4a90e2;
    outline: none;
    box-shadow: 0 0 3px rgba(74, 144, 226, 0.3);
}

/* Material Input Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal-content {
    position: relative;
    background-color: #fff;
    margin: 50px auto;
    padding: 20px;
    width: 80%;
    max-width: 800px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.modal-header {
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5em;
    color: #333;
}

.modal-body {
    margin-bottom: 20px;
}

.transport-section {
    margin-bottom: 30px;
}

.transport-section h3 {
    margin-bottom: 15px;
    color: #666;
    font-size: 1.2em;
}

.transport-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
}

.transport-row label {
    min-width: 120px;
    color: #333;
}

.transport-row input {
    width: 100px;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: right;
    background-color: #fff;
}

.transport-row input:disabled {
    background-color: #f5f5f5;
}

.transport-row .operator {
    margin: 0 10px;
    color: #666;
}

.transport-row .unit {
    margin-left: 10px;
    color: #666;
}

.transport-total {
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.transport-total .total-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.modal-footer button {
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.btn-save {
    background-color: #2c3e50;
    color: white;
    border: none;
}

.btn-cancel {
    background-color: #e74c3c;
    color: white;
    border: none;
}

.select-container {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
}

.select-container select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-width: 200px;
}

.select-container .select-label {
    color: #333;
    min-width: 120px;
}

.select-container .select-action {
    color: #e74c3c;
    cursor: pointer;
    text-decoration: none;
}

.yellow-bg {
    background-color: #fff9c4;
}

.gray-bg {
    background-color: #f5f5f5;
}

/* --- From index.html --- */
.formula-list {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}
.formula-list th,
.formula-list td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}
.formula-list th {
    background-color: #f5f5f5;
    font-weight: bold;
}
.formula-list tr:hover {
    background-color: #f9f9f9;
}
.action-buttons {
    display: flex;
    gap: 8px;
}
.action-buttons button {
    padding: 6px 12px;
    font-size: 14px;
}
.add-button {
    margin-bottom: 20px;
}
.add-button button {
    background-color: #28a745;
}
.add-button button:hover {
    background-color: #218838;
}
.edit-button {
    background-color: #ffc107;
}
.edit-button:hover {
    background-color: #e0a800;
}
.delete-button {
    background-color: #dc3545;
}
.delete-button:hover {
    background-color: #c82333;
}
.copy-button {
    background-color: #17a2b8;
}
.copy-button:hover {
    background-color: #138496;
}
.view-button {
    background-color: #6f42c1;
}
.view-button:hover {
    background-color: #5a32a3;
}
.report-button {
    background-color: #fd7e14;
}
.report-button:hover {
    background-color: #e8690b;
}

/* --- From display_formula.html --- */
.display-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: #f5f5f5;
    min-height: 100vh;
}
.formula-header {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.formula-title {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}
.formula-metadata {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}
.metadata-item {
    display: flex;
    flex-direction: column;
}
.metadata-label {
    font-weight: bold;
    color: #666;
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 5px;
}
.metadata-value {
    color: #333;
    font-size: 14px;
}
.formula-content {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}
.error {
    background-color: #ffebee;
    color: #c62828;
    padding: 15px;
    border-radius: 4px;
    margin: 20px 0;
}
.back-button {
    background-color: #6c757d;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    margin-bottom: 20px;
}
.back-button:hover {
    background-color: #5a6268;
}

/* --- From report.html --- */
.report-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: #f5f5f5;
    min-height: 100vh;
}
.report-header {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.report-title {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}
.report-metadata {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}
.report-content {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.print-button {
    background-color: #17a2b8;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-left: 10px;
}
.print-button:hover {
    background-color: #138496;
}
.value-display {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 14px;
    color: #495057;
    min-width: 80px;
    text-align: center;
    display: inline-block;
}
.material-display {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 14px;
    color: #495057;
    min-width: 80px;
    text-align: center;
    display: inline-block;
}
.material-detail-button {
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    margin-left: 5px;
}
.material-detail-button:hover {
    background-color: #5a6268;
}
@media print {
    .back-button, .print-button {
        display: none;
    }
    .report-container {
        background-color: white;
        padding: 0;
    }
    .report-header, .report-content {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* --- Material Selection Modal --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #ddd;
    background-color: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.modal-header h2 {
    margin: 0;
    color: #333;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.modal-body {
    padding: 20px;
}

.material-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.material-table th,
.material-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.material-table th {
    background-color: #f5f5f5;
    font-weight: bold;
}

.material-table tr:hover {
    background-color: #f9f9f9;
}

.select-material-btn {
    background-color: #28a745;
    color: white;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.select-material-btn:hover {
    background-color: #218838;
} 