:root {
    color-scheme: light;
    font-family:
        Inter, ui-sans-serif, system-ui, -apple-system,
        BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #eef3f8;
    color: #172033;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, #dcecff, transparent 35%),
        #eef3f8;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    align-items: flex-start;
    padding: 2.5rem clamp(1rem, 4vw, 4rem);
    color: white;
    background: linear-gradient(135deg, #12355b, #1f6ca8);
}

.eyebrow,
.section-label {
    margin: 0 0 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.75rem;
    font-weight: 700;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0.75rem;
}

.subtitle {
    margin-bottom: 0;
    max-width: 760px;
    color: #dcecff;
}

.back-link {
    color: white;
    text-decoration: none;
    border: 1px solid rgb(255 255 255 / 45%);
    border-radius: 999px;
    padding: 0.7rem 1rem;
    white-space: nowrap;
}

.page-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
    gap: 1.5rem;
    padding: 1.5rem clamp(1rem, 4vw, 4rem) 3rem;
}

.panel {
    background: rgb(255 255 255 / 94%);
    border: 1px solid #d7e0ea;
    border-radius: 18px;
    padding: 1.35rem;
    box-shadow: 0 16px 40px rgb(23 32 51 / 8%);
}

.panel-heading,
.geometry-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.badge {
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background: #e2f1ff;
    color: #135d91;
    font-size: 0.8rem;
    font-weight: 700;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

label {
    display: grid;
    gap: 0.4rem;
    font-size: 0.9rem;
    font-weight: 650;
}

input,
select,
button {
    font: inherit;
}

input,
select {
    width: 100%;
    padding: 0.72rem 0.8rem;
    border: 1px solid #bfcbd8;
    border-radius: 10px;
    background: white;
}

fieldset {
    margin: 1.3rem 0;
    padding: 1rem;
    border: 1px solid #d3dee9;
    border-radius: 12px;
}

legend {
    padding: 0 0.4rem;
    font-weight: 700;
}

.geometry-heading {
    margin-top: 1.5rem;
}

.help-text {
    color: #5c6878;
    font-size: 0.9rem;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 0.75rem;
    border-bottom: 1px solid #dce4ec;
    text-align: left;
    white-space: nowrap;
}

th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #526173;
}

.primary-button,
.secondary-button {
    border: 0;
    border-radius: 10px;
    padding: 0.78rem 1rem;
    cursor: pointer;
    font-weight: 750;
}

.primary-button {
    width: 100%;
    color: white;
    background: #1769aa;
}

.secondary-button {
    color: #155884;
    background: #e6f2fb;
}

.status-message {
    min-height: 1.4rem;
    margin: 1rem 0 0;
}

.status-message.error {
    color: #a32727;
}

.empty-state {
    padding: 3rem 1rem;
    text-align: center;
    color: #687587;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
}

.result-card {
    display: grid;
    gap: 0.3rem;
    padding: 1rem;
    border: 1px solid #dbe4ed;
    border-radius: 12px;
    background: #f8fbfd;
}

.result-card span,
.result-card small {
    color: #667487;
}

.result-card strong {
    font-size: 1.25rem;
}

.result-section {
    margin-top: 1.4rem;
}

.geometry-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 1rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid #e0e7ee;
}

@media (max-width: 900px) {
    .page-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .topbar {
        display: block;
    }

    .back-link {
        display: inline-block;
        margin-top: 1.2rem;
    }

    .form-grid,
    .result-grid {
        grid-template-columns: 1fr;
    }

    .geometry-heading {
        align-items: flex-start;
        flex-direction: column;
    }
}

.chart-box {
    position: relative;
    width: 100%;
    overflow: hidden;
    border: 1px solid #dbe4ed;
    border-radius: 14px;
    background: #ffffff;
}

.chart-box canvas {
    display: block;
    width: 100%;
    height: auto;
}

.geometry-chart-box {
    min-height: 230px;
}

.pattern-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.polar-chart-box {
    max-width: 520px;
    margin: 0 auto;
}

.chart-note {
    margin: -0.4rem 0 0.8rem;
    color: #667487;
    font-size: 0.85rem;
}

.warning-box {
    margin-top: 1rem;
    padding: 0.9rem 1rem;
    border: 1px solid #e6c46b;
    border-radius: 12px;
    background: #fff8df;
    color: #6f5200;
}

@media (max-width: 900px) {
    .pattern-grid {
        grid-template-columns: 1fr;
    }
}

.results-panel .chart-box {
    width: 100%;
}

@media (min-width: 1100px) {
    .pattern-grid {
        grid-template-columns: 1fr;
    }

    .polar-chart-box {
        max-width: 620px;
    }
}

/* Evita estirar los canvas y mejora la nitidez. */
.results-panel #geometry-canvas,
.results-panel #swr-canvas,
.results-panel #azimuth-canvas,
.results-panel #elevation-canvas {
    min-height: 0;
    width: 100%;
    height: auto;
}

#geometry-canvas {
    aspect-ratio: 900 / 320;
}

#swr-canvas {
    aspect-ratio: 900 / 360;
}

#azimuth-canvas,
#elevation-canvas {
    aspect-ratio: 1 / 1;
}

.impedance-left-section {
    margin-top: 1.5rem;
}

.impedance-left-section .table-wrapper {
    max-height: 720px;
    overflow: auto;
}

.impedance-left-section table {
    font-size: 0.84rem;
}

.impedance-left-section thead {
    position: sticky;
    top: 0;
    z-index: 1;
    background: white;
}

.matching-warning {
    margin-bottom: 1rem;
    padding: 0.95rem 1rem;
    border: 1px solid #e2b650;
    border-left: 5px solid #d18a00;
    border-radius: 12px;
    background: #fff8df;
    color: #604900;
}

.matching-warning.good-match {
    border-color: #79bd96;
    border-left-color: #278653;
    background: #eaf8ef;
    color: #185b38;
}

.matching-warning strong {
    display: block;
    margin-bottom: 0.35rem;
}

.matching-warning p {
    margin: 0;
    line-height: 1.45;
}
