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

:root {
    --primary: #2E86AB;
    --primary-dark: #1a5f7a;
    --accent: #E94F37;
    --bg: #f8f9fa;
    --card-bg: #ffffff;
    --text: #1a1a2e;
    --text-light: #6c757d;
    --border: #e0e0e0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

.container {
    max-width: 700px;
    margin: 0 auto;
    padding: 0.5rem 1.5rem;
}

header {
    text-align: center;
    margin-bottom: 0.5rem;
}

h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.2rem;
}

.subtitle {
    color: var(--text-light);
    font-size: 0.95rem;
}

main {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.input-section {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.input-group {
    margin-bottom: 0.6rem;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.2rem;
    font-size: 0.85rem;
}

.optional {
    font-weight: 400;
    color: var(--text-light);
    font-size: 0.85em;
}

.income-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 0.35rem 0.6rem;
    transition: border-color 0.2s;
}

.income-input-wrapper:focus-within {
    border-color: var(--primary);
}

.currency {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-light);
    margin-right: 0.25rem;
}

.income-input-wrapper input {
    border: none;
    background: transparent;
    font-size: 1.1rem;
    font-weight: 600;
    width: 100%;
    outline: none;
    font-family: inherit;
}

input[type="range"] {
    width: 100%;
    margin: 0.3rem 0 0.15rem;
    -webkit-appearance: none;
    background: transparent;
}

input[type="range"]::-webkit-slider-track {
    height: 6px;
    background: linear-gradient(to right, var(--primary), var(--accent));
    border-radius: 3px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: white;
    border: 2px solid var(--primary);
    border-radius: 50%;
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.6rem;
    color: var(--text-light);
    margin-top: 0.15rem;
}

.slider-labels span {
    text-align: center;
    min-width: 0;
}

.metro-presets {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
}

.preset-btn {
    padding: 0.25rem 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    color: var(--text);
}

.preset-btn:hover {
    border-color: var(--primary);
    background: #f0f7fa;
}

.preset-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.select-wrapper {
    position: relative;
}

.select-wrapper input {
    width: 100%;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
}

.select-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
}

.dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid var(--primary);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dropdown.hidden {
    display: none;
}

.dropdown-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background: var(--bg);
}

.selected-metro {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--primary);
    color: white;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
}

.selected-metro.hidden {
    display: none;
}

.selected-metro #metro-name {
    flex: 1;
}

.selected-metro #metro-cola {
    opacity: 0.8;
}

.selected-metro button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.advanced-section {
    margin: 0.4rem 0 0;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.advanced-section summary {
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--text-light);
}

.advanced-section[open] summary {
    border-bottom: 1px solid var(--border);
}

.advanced-inputs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    padding: 0.5rem;
}

@media (max-width: 500px) {
    .advanced-inputs {
        grid-template-columns: repeat(2, 1fr);
    }
}

.param-group label {
    font-size: 0.75rem;
    margin-bottom: 0.15rem;
}

.param-desc {
    font-weight: 400;
    color: var(--text-light);
    font-size: 0.75em;
}

.param-group input {
    width: 100%;
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.85rem;
    font-family: inherit;
}

.param-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.formula-display {
    text-align: center;
    padding: 0.5rem;
    color: var(--text-light);
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
}

.calculate-btn {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    font-family: inherit;
}

.calculate-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(46, 134, 171, 0.35);
}

.calculate-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

.results-section {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.results-section.hidden {
    display: none;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.result-card {
    background: var(--bg);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    text-align: center;
}

.result-card.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.result-card.primary .result-value {
    font-size: 1.4rem;
}

.result-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 500;
    margin-bottom: 0.15rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.result-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
}

.result-subvalue {
    display: block;
    font-size: 0.7rem;
    margin-top: 0.1rem;
    opacity: 0.7;
}

.plot-container img {
    width: 100%;
    height: auto;
    border-radius: 6px;
}

.plot-controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.35rem;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-light);
    cursor: pointer;
}

.toggle-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

.breakeven-info {
    margin-top: 0.5rem;
    padding: 0.35rem 0.6rem;
    background: linear-gradient(135deg, #f0faf0, #e8f8e8);
    border-radius: 6px;
    border-left: 3px solid #28a745;
    font-size: 0.75rem;
}

.breakeven-label {
    font-weight: 600;
    color: #1e7e34;
    margin-right: 0.4rem;
    font-size: 0.8rem;
}

#breakeven-region {
    font-weight: 500;
    font-size: 0.9em;
    opacity: 0.85;
}

.breakeven-value {
    font-weight: 700;
    color: #28a745;
    font-size: 0.85rem;
}

.breakeven-detail {
    display: block;
    margin-top: 0.1rem;
    font-size: 0.65rem;
    color: var(--text-light);
    font-style: italic;
}

.population-estimate {
    margin-top: 0.5rem;
    padding: 0.35rem 0.6rem;
    background: linear-gradient(135deg, #f0f7fa, #e8f4f8);
    border-radius: 6px;
    border-left: 3px solid var(--primary);
    font-size: 0.7rem;
}

.pop-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 0.4rem;
    align-items: baseline;
    margin-bottom: 0.15rem;
}

.pop-row.comparison {
    margin-top: 0.35rem;
    padding-top: 0.35rem;
    border-top: 1px dashed var(--border);
}

.pop-label {
    color: var(--text-light);
    min-width: 130px;
}

.pop-value {
    font-weight: 700;
    color: var(--primary-dark);
    min-width: 90px;
}

.pop-detail {
    color: var(--text-light);
    font-size: 0.65rem;
}

.pop-diff {
    font-weight: 600;
    font-size: 0.65rem;
}

.pop-diff.positive {
    color: #28a745;
}

.pop-diff.negative {
    color: var(--accent);
}

.pop-note {
    margin-top: 0.25rem;
    font-size: 0.6rem;
    color: var(--text-light);
    font-style: italic;
}

footer {
    margin-top: 0.5rem;
    text-align: center;
    padding: 0.25rem 0;
}

.philosophy {
    font-style: italic;
    color: var(--text-light);
    font-size: 0.8rem;
    line-height: 1.5;
    max-width: 600px;
    margin: 0 auto;
}

.credit {
    display: none;
}

/* Curve Fitting Section */
.curve-fitting-content {
    padding: 0.5rem;
}

.curve-fitting-desc {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.target-points-container {
    margin-bottom: 0.5rem;
}

.target-points-header {
    display: grid;
    grid-template-columns: 1fr 1fr 24px;
    gap: 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 0 0.25rem 0.25rem;
}

.target-point-row {
    display: grid;
    grid-template-columns: 1fr 1fr 24px;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.35rem;
}

.target-income-wrapper,
.target-rate-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0.25rem 0.4rem;
}

.target-income-wrapper:focus-within,
.target-rate-wrapper:focus-within {
    border-color: var(--primary);
}

.currency-small {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-light);
    margin-right: 0.15rem;
}

.target-income,
.target-rate {
    border: none;
    background: transparent;
    font-size: 0.85rem;
    font-weight: 500;
    width: 100%;
    outline: none;
    font-family: inherit;
}

.target-rate {
    text-align: right;
    -moz-appearance: textfield;
}

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

.percent-sign {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-left: 0.15rem;
}

.remove-point-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 1.1rem;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.remove-point-btn:hover {
    background: #fee;
    color: var(--accent);
}

.add-point-btn {
    width: 100%;
    padding: 0.35rem;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: 5px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.add-point-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #f0f7fa;
}

.fit-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.fit-curve-btn {
    flex: 1;
    padding: 0.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.fit-curve-btn:hover:not(:disabled) {
    background: var(--primary-dark);
}

.fit-curve-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

.reset-curve-btn {
    padding: 0.5rem 0.75rem;
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.reset-curve-btn:hover {
    border-color: var(--text-light);
    color: var(--text);
}

.fit-result {
    margin-top: 0.5rem;
    padding: 0.35rem 0.5rem;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: 500;
}

.fit-result.success {
    background: #e8f5e9;
    color: #2e7d32;
    border-left: 3px solid #28a745;
}

.fit-result.error {
    background: #ffebee;
    color: #c62828;
    border-left: 3px solid var(--accent);
}

.fit-result.hidden {
    display: none;
}

/* Footer */
.site-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    margin-top: 2rem;
    font-size: 0.85rem;
    color: #666;
}

.site-footer a {
    color: var(--primary);
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}
