:root {
    --content-width: 1000px;
}

body {
    background: #f0f2f5;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    margin: 20px;
}

.control-panel {
    box-sizing: border-box;
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto 24px;
    padding: 10px 12px;
    background: linear-gradient(180deg, #aee1ff 0%, #cbeeff 28%, #e6f6ff 72%, #dff1ff 100%);
    border: 1px solid #7fc2e3;
    border-radius: 8px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 10px 22px rgba(15, 62, 92, 0.06);
}

.control-form {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(6, minmax(82px, 1fr)) auto;
    gap: 6px;
    align-items: end;
}

.control-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.control-field label {
    color: #2a6078;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.1;
}

.control-field input,
.control-field select {
    box-sizing: border-box;
    height: 32px;
    width: 100%;
    min-width: 0;
    padding: 0 8px;
    border: 1px solid #b9d7e8;
    border-radius: 5px;
    background: #fff;
    color: #234b5d;
    font-size: 13px;
}

.control-field input:focus,
.control-field select:focus {
    outline: none;
    border-color: #00aaff;
    box-shadow: 0 0 0 3px rgba(0, 170, 255, 0.16);
}

.control-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: nowrap;
    justify-self: end;
}

.control-submit,
.control-reset {
    box-sizing: border-box;
    height: 32px;
    padding: 0 12px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.control-submit {
    border: 0;
    background: #00aaff;
    color: #fff;
}

.control-reset {
    display: inline-flex;
    align-items: center;
    border: 1px solid #b9d7e8;
    background: #fff;
    color: #2a6078;
}

.control-hint {
    width: 100%;
    margin: 10px 0 0;
    color: #51646f;
    font-size: 13px;
}

.scroll-top-button {
    position: fixed;
    display: flex;
    align-items: center;
    justify-content: center;
    right: 24px;
    bottom: 24px;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid rgba(0, 170, 255, 0.38);
    border-radius: 50%;
    background: rgba(0, 170, 255, 0.96);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(0, 77, 122, 0.18);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease, background-color 0.18s ease;
    z-index: 1000;
}

.scroll-top-button-icon {
    transform: translateY(-2px);
}

.scroll-top-button:hover {
    background: #0095df;
}

.scroll-top-button.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

@media (max-width: 900px) {
    .control-form {
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
        gap: 8px;
    }

    .control-actions {
        grid-column: 1 / -1;
        justify-self: start;
    }

    .scroll-top-button {
        right: 16px;
        bottom: 16px;
    }
}

/* Подсветка строк first_up / first_down */
table.styled-table tbody tr.first-up-row {
    background-color: rgba(40, 167, 69, 0.1); /* мягкий зелёный */
}

table.styled-table tbody tr.first-down-row {
    background-color: rgba(220, 53, 69, 0.1); /* мягкий красный */
}

/* Hover строки (синий) поверх подсветки */
table.styled-table tbody tr:hover {
    background-color: rgba(153, 204, 255, 0.6); /* мягкий голубой с прозрачностью 50% */
}

/* Цвета процентов */
.percent-value.percent-positive { color: #28a745; font-weight: bold; }
.percent-value.percent-negative { color: #cf3b49; font-weight: bold; }
.percent-value.percent-zero { color: #777; font-weight: bold; }
.value-badge {
    display: inline;
    padding: 0 5px;
    border-radius: 6px;
    line-height: inherit;
    white-space: nowrap;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}
.value-badge.percent-positive {
    background-color: rgba(40, 167, 69, 0.14);
}
.value-badge.percent-negative {
    background-color: rgba(220, 53, 69, 0.12);
}
.value-badge.percent-zero {
    background-color: rgba(108, 117, 125, 0.10);
}
.percent-positive-range,
.percent-negative-range {
    font-family: Bahnschrift, "Franklin Gothic Medium", "Segoe UI", sans-serif;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.percent-positive-range {color: green; }
.percent-negative-range {color: red; }
.table-anchor {
    scroll-margin-top: 12px;
}

.percent-count { color: #777; font-weight: normal; } /* скобки всегда серые */

/* Таблица */
table.styled-table {
    border-collapse: collapse;
    width: 100%;
    max-width: var(--content-width);
    margin: 15px auto;
    font-size: 12px;
    background-color: #fff;
}

table.styled-table th,
table.styled-table td {
    border: 1px solid #ccc;
    padding: 6px 8px;
    text-align: center;
}

table.styled-table th.cell-highlight,
table.styled-table td.cell-highlight {
    box-shadow: inset 0 0 0 2px rgba(0, 170, 255, 0.45);
}

table.styled-table th.cell-highlight-axis,
table.styled-table td.cell-highlight-axis {
    box-shadow: inset 0 0 0 2px rgba(0, 170, 255, 0.32);
}

table.styled-table td.cell-highlight-strong {
    box-shadow: inset 0 0 0 3px rgba(0, 170, 255, 0.65);
}

table.styled-table td.row-highlight {
    border-top: 2px solid rgba(0, 170, 255, 0.65);
    border-bottom: 2px solid rgba(0, 170, 255, 0.65);
}

table.styled-table td.row-highlight-left {
    border-left: 2px solid rgba(0, 170, 255, 0.65);
}

table.styled-table td.row-highlight-right {
    border-right: 2px solid rgba(0, 170, 255, 0.65);
}

table.styled-table td.column-highlight {
    border-left: 2px solid rgba(0, 170, 255, 0.65);
    border-right: 2px solid rgba(0, 170, 255, 0.65);
}

table.styled-table td.column-highlight-start {
    border-top: 2px solid rgba(0, 170, 255, 0.65);
}

table.styled-table td.column-highlight-end {
    border-bottom: 2px solid rgba(0, 170, 255, 0.65);
}

table.styled-table thead {
    background-color: #00aaff;
    color: #fff;
}

h2 {
    font-size: 1.6em;
    color: #333;
    font-weight: 600;
    margin-top: 30px;
    margin-bottom: 15px;
    padding-left: 10px;
    border-left: 5px solid #00aaff;
}

h2.table-anchor {
    font-family: Candara, Optima, "Trebuchet MS", sans-serif;
    font-weight: 700;
    letter-spacing: 0.015em;
}
