/* Copyright (c) Vanguard Consulting Oy. All rights reserved. */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Calibri', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #F7F7F7;
    color: #2d3748;
    line-height: 1.6;
}

header {
    background: #067680;
    color: white;
    padding: 1.5rem 2rem;
    text-align: center;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 700;
}

header .subtitle {
    font-size: 0.95rem;
    opacity: 0.85;
    margin-top: 0.3rem;
}

nav {
    background: #067680;
    display: flex;
    gap: 0;
    justify-content: center;
    flex-wrap: wrap;
}

nav a {
    color: white;
    text-decoration: none;
    padding: 0.7rem 1.5rem;
    font-size: 0.9rem;
    transition: background 0.2s;
}

nav a:hover {
    background: #088A95;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

section {
    margin-bottom: 2rem;
}

section h2 {
    font-size: 1.4rem;
    color: #067680;
    border-bottom: 2px solid #067680;
    padding-bottom: 0.4rem;
    margin-bottom: 1rem;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.card {
    background: white;
    border-radius: 8px;
    padding: 1.2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
}

.card h3 {
    font-size: 1.05rem;
    color: #2d3748;
    margin-bottom: 0.8rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

th, td {
    padding: 0.5rem 0.7rem;
    text-align: right;
    border-bottom: 1px solid #e2e8f0;
}

th {
    background: #E7E6E6;
    font-weight: 600;
    color: #4a5568;
    position: sticky;
    top: 0;
}

td:first-child, th:first-child {
    text-align: left;
}

tbody tr:hover {
    background: #F9FAFB;
}

.chart-container {
    position: relative;
    height: 350px;
}

.chart-container-small {
    position: relative;
    height: 220px;
    width: 220px;
    flex-shrink: 0;
}

.chart-table-row {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.chart-table-row table {
    flex: 1;
}

.params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.8rem;
}

.params-grid label {
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    color: #4a5568;
    gap: 0.3rem;
}

.params-grid input {
    padding: 0.4rem 0.6rem;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    font-size: 0.9rem;
}

.params-grid input:focus {
    outline: none;
    border-color: #088A95;
    box-shadow: 0 0 0 2px rgba(6, 118, 128, 0.2);
}

.table-scroll {
    max-height: 500px;
    overflow-y: auto;
}

.button-row {
    display: flex;
    gap: 0.8rem;
    margin-top: 1rem;
}

.btn-primary {
    background: #067680;
    color: white;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-primary:hover {
    background: #088A95;
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-secondary:hover {
    background: #cbd5e0;
}

.btn-link {
    background: none;
    border: none;
    color: #067680;
    text-decoration: underline;
    cursor: pointer;
    font-size: inherit;
}

.upload-area {
    border: 2px dashed #cbd5e0;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    color: #718096;
    transition: border-color 0.2s;
}

.upload-area.dragover {
    border-color: #088A95;
    background: #ebf8ff;
}

.status-text {
    font-size: 0.85rem;
    color: #718096;
    margin-top: 0.5rem;
}

.status-text.success {
    color: #38a169;
}

.status-text.error {
    color: #e53e3e;
}

footer {
    text-align: center;
    padding: 1.5rem;
    color: #a0aec0;
    font-size: 0.85rem;
}

/* KPI row */
.kpi-row {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.kpi-card {
    flex: 1;
    min-width: 160px;
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    text-align: center;
    border-top: 3px solid #067680;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #067680;
}

.kpi-label {
    font-size: 0.8rem;
    color: #4a5568;
    margin-top: 0.2rem;
}

.kpi-sub {
    font-size: 0.7rem;
    color: #a0aec0;
    margin-top: 0.1rem;
}

/* KPI mini (Yhteenveto card) */
.kpi-mini-row {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}

.kpi-mini {
    flex: 1;
    text-align: center;
}

.kpi-mini-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: #067680;
}

.kpi-mini-label {
    display: block;
    font-size: 0.7rem;
    color: #718096;
}

/* Range slider */
.range-slider-container {
    display: flex;
    gap: 2rem;
    align-items: center;
    flex-wrap: wrap;
}

.range-slider-container label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    color: #4a5568;
}

.range-slider-container input[type="range"] {
    width: 200px;
    accent-color: #067680;
}

.range-slider-container span {
    font-weight: 600;
    min-width: 36px;
}

/* Infra tables grid */
.infra-tables-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1rem;
}

.infra-tables-grid h4 {
    font-size: 0.92rem;
    color: #2d3748;
    margin-bottom: 0.4rem;
}

.table-scroll-sm {
    max-height: 300px;
    overflow: auto;
}

.infra-input {
    padding: 0.2rem 0.3rem;
    border: 1px solid #cbd5e0;
    border-radius: 3px;
    font-size: 0.8rem;
    text-align: right;
}

.infra-input:focus {
    outline: none;
    border-color: #088A95;
    box-shadow: 0 0 0 2px rgba(6, 118, 128, 0.2);
}

.card-desc {
    font-size: 0.82rem;
    color: #718096;
    margin-bottom: 0.8rem;
}

/* Type case styles */
.type-case-controls {
    margin-bottom: 1rem;
}

.type-case-controls select {
    padding: 0.4rem 0.6rem;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    font-size: 0.9rem;
    min-width: 200px;
}

.type-case-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.type-case-section {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.8rem;
}

.type-case-section h4 {
    font-size: 0.95rem;
    color: #067680;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.3rem;
}

.type-case-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.type-case-half h5 {
    font-size: 0.85rem;
    color: #4a5568;
    margin-bottom: 0.3rem;
}

.tc-table {
    font-size: 0.78rem;
}

.tc-table th {
    font-size: 0.75rem;
    padding: 0.3rem 0.4rem;
}

.tc-table td {
    padding: 0.3rem 0.4rem;
}

.tc-dropdown {
    font-size: 0.72rem;
    padding: 0.2rem;
    border: 1px solid #cbd5e0;
    border-radius: 3px;
    max-width: 280px;
}

.tc-total {
    background: #E7E6E6;
    font-weight: 700;
}

/* Toimintaympäristö tab */
.ty-total-row {
    background: #E7E6E6;
    font-weight: 700;
}

.param-hint {
    font-size: 0.75rem;
    color: #a0aec0;
}

#toimintaymparisto-section .card h3 {
    color: #067680;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.4rem;
}

#toimintaymparisto-section .table-scroll table {
    font-size: 0.82rem;
}

#toimintaymparisto-section .table-scroll table th {
    font-size: 0.78rem;
    white-space: nowrap;
}

#toimintaymparisto-section .table-scroll table td:first-child {
    white-space: nowrap;
    min-width: 180px;
}

@media (max-width: 768px) {
    .card-grid {
        grid-template-columns: 1fr;
    }
    .chart-table-row {
        flex-direction: column;
    }
    .chart-container-small {
        width: 100%;
    }
    .params-grid {
        grid-template-columns: 1fr;
    }
    nav {
        flex-direction: column;
    }
    nav a {
        text-align: center;
    }
    .kpi-row {
        flex-direction: column;
    }
    .type-case-pair {
        grid-template-columns: 1fr;
    }
    .infra-tables-grid {
        grid-template-columns: 1fr;
    }
    .range-slider-container {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Editable tehoristeily inputs */
.tehoristeily-input {
    border: 1px solid #cbd5e0;
    border-radius: 3px;
    padding: 2px 4px;
    font-size: 0.85rem;
    background: #fffbeb;
}
.tehoristeily-input:focus {
    outline: 2px solid #3182ce;
    background: #fff;
}
td.interpolated {
    color: #718096;
    font-style: italic;
}
