body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background: #f7f7f7;
    color: #333;
}

header {
    background: #fff;
    color: #333;
    padding: 1rem 0;
    text-align: center;
    border-bottom: 1px solid #e5e5e5;
}

header h1 {
    margin: 0;
    font-size: 1.8em;
}
header p {
    margin: 0.5em 0 0;
    color: #666;
}

main {
    padding: 1.5rem;
    max-width: 900px;
    margin: 20px auto;
}

#calculator {
    display: flex;
    gap: 2rem;
}

#input-form {
    flex: 1;
}

#results-area {
    flex: 1;
    background: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
    align-self: flex-start; /* Aligns to the top */
}

.form-section {
    border: 1px solid #e5e5e5;
    padding: 1rem 1.5rem 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    background: #fff;
}

.form-section legend {
    font-weight: 600;
    font-size: 1.2em;
    padding: 0 0.5em;
    color: #333;
}

.form-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-row label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    flex-grow: 1;
}

.form-row input[type="number"] {
    width: 150px;
    padding: 8px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: right;
}

.form-row select {
    width: 170px;
    padding: 8px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
}

input:disabled,
select:disabled {
    background-color: #f0f0f0;
    cursor: not-allowed;
    color: #888;
}

.form-row.estimated input[type="number"] {
    background-color: #fff4d6;
    border-color: #f0c36d;
    color: #8a6d1d;
}

.form-row.estimated select {
    background-color: #fff4d6;
    border-color: #f0c36d;
    color: #8a6d1d;
}

#results-area h2 {
    margin-top: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

#results-area h3 {
    font-size: 1.1em;
    color: #333;
    margin-top: 1.5rem;
}

#results-area ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#calculated-items ul li {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    font-weight: 500;
}
#calculated-items ul li.estimate {
    color: #8a6d1d;
}
#calculated-items ul li:last-child {
    border-bottom: none;
}

#uncalculated-items ul {
    color: #777;
}
#uncalculated-items ul li {
    padding: 4px 0;
}

#results-actions {
    margin-top: 2rem;
    border-top: 1px solid #eee;
    padding-top: 1.5rem;
}

#results-actions .actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

#results-actions label {
    font-weight: 600;
}

#result-name {
    flex: 1 1 200px;
    min-width: 180px;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

#results-actions button {
    padding: 0.5rem 0.9rem;
    border: none;
    border-radius: 4px;
    background-color: #007bff;
    color: #fff;
    cursor: pointer;
}

#results-actions button:hover:not(:disabled) {
    opacity: 0.9;
}

#results-actions button:disabled {
    background-color: #9bbef5;
    cursor: not-allowed;
}

#results-actions .actions-note {
    color: #666;
    font-size: 0.9em;
    margin: 0 0 0.5rem;
}

#results-actions .actions-feedback {
    min-height: 1.2em;
    margin: 0 0 0.75rem;
    font-size: 0.9em;
    color: #007bff;
}

#results-actions .actions-feedback[data-type="error"] {
    color: #d9534f;
}

#results-actions .actions-feedback[data-type="success"] {
    color: #28a745;
}

#saved-results ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#saved-results li {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

#saved-results li:last-child {
    border-bottom: none;
}

#saved-results li.empty {
    color: #777;
    font-style: italic;
}

#saved-results .saved-title {
    font-weight: 600;
    margin-right: auto;
}

#saved-results .saved-meta {
    color: #666;
    font-size: 0.85em;
}

#saved-results .saved-count {
    background-color: #f1f3f5;
    border-radius: 12px;
    padding: 0.2rem 0.6rem;
    font-size: 0.85em;
    color: #555;
}

#saved-results button {
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: 4px;
    background-color: #6c757d;
    color: #fff;
    cursor: pointer;
}

#saved-results button[data-action="load"] {
    background-color: #007bff;
}

#saved-results button[data-action="delete"] {
    background-color: #d9534f;
}

#saved-results button:disabled {
    background-color: #c0c4c7;
    cursor: not-allowed;
    opacity: 0.85;
}

#saved-results button:hover:not(:disabled) {
    opacity: 0.9;
}


footer {
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 20px;
    color: #888;
}

/* Index Page Specific */
#html-list ul {
    list-style: none;
    padding: 0;
}

#html-list li {
    border-bottom: 1px #ddd solid;
    padding: 10px 0;
}

#html-list a {
    text-decoration: none;
    color: #333;
}

#html-list a:hover {
    color: #007bff;
}
