* { box-sizing: border-box; }

:root {
    --navy: #082f49;
    --blue: #0369a1;
    --light: #f0f9ff;
    --line: #cbd5e1;
    --text: #172033;
    --muted: #64748b;
    --ok: #15803d;
    --warn: #b45309;
    --bad: #b91c1c;
}

body {
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    background: #f1f5f9;
    color: var(--text);
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px max(20px, calc((100% - 1180px) / 2));
    background: linear-gradient(120deg, var(--navy), var(--blue));
    color: white;
}

h1 { margin: 0 0 4px; font-size: 28px; }
header p { margin: 0; color: #bae6fd; }
h2 { margin: 0 0 16px; color: var(--navy); }
h3 { margin-top: 24px; }

.badge {
    padding: 8px 12px;
    border: 2px solid #7dd3fc;
    border-radius: 12px;
    font-size: 24px;
    font-weight: 800;
}

main { max-width: 1180px; margin: 24px auto; padding: 0 16px; }

.card {
    margin-bottom: 18px;
    padding: 20px;
    background: white;
    border-radius: 14px;
    box-shadow: 0 4px 18px #0f172a12;
}

.intro { display: flex; gap: 12px; background: #fff7ed; border-left: 5px solid #f59e0b; }
.intro span { color: #7c2d12; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-note { margin: -8px 0 16px; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.meta { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.wide { grid-column: span 2; }
label { color: #334155; font-size: 13px; font-weight: 600; }

input,
textarea {
    width: 100%;
    margin-top: 6px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
}

input:focus,
textarea:focus,
button:focus-visible { outline: 3px solid #7dd3fc; outline-offset: 2px; }

.input-field { display: flex; flex-direction: column; min-width: 0; }
.input-label { display: block; margin-bottom: 6px; color: #334155; font-size: 13px; font-weight: 600; }
.input-with-unit { position: relative; width: 100%; }
.input-with-unit input { margin-top: 0; padding-right: 64px; }
.input-unit {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    pointer-events: none;
}
.help { display: block; min-height: 15px; margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.35; }

.primary,
.secondary,
.tab-button { border: 0; border-radius: 9px; padding: 11px 15px; font-weight: 700; cursor: pointer; }
.primary { margin-top: 18px; background: var(--blue); color: white; }
.secondary { background: #e0f2fe; color: #075985; }
button:disabled { cursor: not-allowed; opacity: .55; }
.validation { margin-top: 14px; color: var(--bad); }
.hidden { display: none; }

.tab-buttons { display: flex; gap: 6px; padding: 0 4px; }
.tab-button {
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 10px 10px 0 0;
    background: #e2e8f0;
    color: #475569;
}
.tab-button:hover { background: #dbeafe; color: var(--navy); }
.tab-button.active { background: white; color: var(--blue); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-card { border-top: 3px solid var(--blue); border-top-left-radius: 4px; }



.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpis.compact { margin-top: 18px; }
.kpi { padding: 16px; border: 1px solid #bae6fd; border-radius: 12px; background: var(--light); }
.kpi span { display: block; color: var(--muted); font-size: 12px; }
.kpi strong { display: block; margin-top: 5px; color: var(--navy); font-size: 24px; }
.kpi.kt-pass { background: #dcfce7; border-color: #86efac; }
.kpi.kt-pass strong { color: #166534; }
.kpi.kt-caution { background: #fef3c7; border-color: #fcd34d; }
.kpi.kt-caution strong { color: #92400e; }
.kpi.kt-fail { background: #fee2e2; border-color: #fca5a5; }
.kpi.kt-fail strong { color: #991b1b; }

.status { padding: 8px 12px; border-radius: 999px; font-weight: 700; }
.status.pass, .ok { background: #dcfce7; color: #166534; }
.status.caution, .warn { background: #fef3c7; color: #92400e; }
.status.fail, .bad { background: #fee2e2; color: #991b1b; }
.details, .checks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 18px; }
.row { display: flex; justify-content: space-between; gap: 15px; padding: 8px 0; border-bottom: 1px solid #e2e8f0; }
.row span:first-child { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions .secondary { margin-top: 18px; }
footer { padding: 10px 20px 30px; color: var(--muted); text-align: center; }

@media (max-width: 800px) {
    .grid, .meta { grid-template-columns: 1fr 1fr; }
    .kpis { grid-template-columns: 1fr 1fr; }
    .wide { grid-column: span 2; }
}

@media (max-width: 520px) {
    .grid, .meta, .kpis, .details, .checks { grid-template-columns: 1fr; }
    .wide { grid-column: auto; }
    .bar, .intro { flex-direction: column; align-items: flex-start; }
    .tab-buttons { display: grid; grid-template-columns: 1fr 1fr; }
    .checkbox-control { width: 100%; min-width: 0; }
}

@media print {
    header, .intro, .tab-buttons, #calculateBtn, #calculateRiserBtn, .actions, footer, #importBtn, .checkbox-control, .not-applicable-message { display: none !important; }
    body { background: white; }
    .card { padding: 10px; box-shadow: none; }
    .hidden { display: block; }
}

.export-note{margin:12px 0 0;color:var(--muted);font-size:12px}.loading{opacity:.65;pointer-events:none}.result-actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:18px}.result-actions button{margin-top:0}.api-status{margin:12px 0 0;color:var(--muted)}
