:root {
    --bg-page: #111827;
    --bg-card: #1f2933;
    --bg-card-soft: #111827;
    --bg-header: #0b1120;
    --bg-input: #111827;
    --bg-input-hover: #111827;
    --bg-input-border: #374151;
    --bg-input-border-focus: #60a5fa;

    --text-main: #e5e7eb;
    --text-muted: #9ca3af;
    --text-strong: #f9fafb;
    --text-danger: #fecaca;

    --accent: #3b82f6;
    --accent-soft: rgba(59, 130, 246, 0.15);
    --accent-strong: #2563eb;

    --btn-primary-bg: #3b82f6;
    --btn-primary-bg-hover: #2563eb;
    --btn-secondary-bg: #374151;
    --btn-secondary-bg-hover: #4b5563;
    --btn-ghost-bg-hover: rgba(249, 250, 251, 0.06);

    --border-radius-lg: 14px;
    --border-radius-md: 10px;
    --border-radius-sm: 6px;

    --shadow-soft: 0 14px 30px rgba(0, 0, 0, 0.45);

    --font-main: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: var(--font-main);
    background: radial-gradient(circle at top, #111827 0, #020617 55%);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

.page-root {
    min-height: 100vh;
    max-width: 1024px;
    margin: 0 auto;
    padding: 20px 16px 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.page-header {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.32), rgba(30, 64, 175, 0.4));
    border-radius: var(--border-radius-lg);
    padding: 18px 20px 16px;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(59, 130, 246, 0.5);
}

.title {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-strong);
}

.subtitle {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
}

.page-main {
    display: grid;
    grid-template-columns: 1.3fr 0.9fr;
    grid-template-rows: auto auto auto;
    gap: 16px;
}

.page-main > #segments-section {
    grid-column: 1 / 3;
}

.page-main > #result-section {
    grid-column: 1 / 3;
}

.page-footer {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

/* Карточки */

.card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: 14px 16px 16px;
    border: 1px solid rgba(15, 23, 42, 0.9);
    box-shadow: var(--shadow-soft);
}

.card-title {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-strong);
}

.card-hint {
    margin: 0 0 12px;
    font-size: 11px;
    color: var(--text-muted);
}

/* Поля и строки */

.field-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.field-row-inline {
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

.field-label {
    font-size: 12px;
    color: var(--text-muted);
}

.field-label-inline {
    font-size: 13px;
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.field-input {
    padding: 6px 8px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--bg-input-border);
    background: var(--bg-input);
    color: var(--text-main);
    font-size: 13px;
    outline: none;
    width: 100%;
    min-height: 30px;
}

.field-input:focus {
    border-color: var(--bg-input-border-focus);
    box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.4);
}

.field-input:hover {
    border-color: #4b5563;
}

/* Таблица сегментов */

.segments-table-wrapper {
    max-height: 320px;
    overflow: auto;
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(15, 23, 42, 0.9);
    background: var(--bg-card-soft);
}

.segments-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.segments-table thead {
    position: sticky;
    top: 0;
    background: #020617;
    z-index: 1;
}

.segments-table th,
.segments-table td {
    padding: 6px 8px;
    text-align: left;
    white-space: nowrap;
}

.segments-table th {
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(55, 65, 81, 0.8);
    font-size: 11px;
    letter-spacing: 0.02em;
}

.segments-table tbody tr:nth-child(odd) {
    background: rgba(15, 23, 42, 0.8);
}

.segments-table tbody tr:nth-child(even) {
    background: rgba(17, 24, 39, 0.9);
}

.segments-table tbody tr.segment-row:hover {
    background: rgba(55, 65, 81, 0.8);
}

.seg-index {
    width: 26px;
    color: var(--text-muted);
}

.seg-role {
    min-width: 110px;
}

.seg-reverse-cell {
    text-align: center;
    width: 80px;
}

/* Кнопки */

.btn {
    border-radius: var(--border-radius-sm);
    border: none;
    cursor: pointer;
    font-size: 13px;
    padding: 6px 10px;
    font-weight: 600;
    transition: background-color 0.12s ease, transform 0.06s ease, box-shadow 0.12s ease;
    color: #f9fafb;
}

.btn:disabled {
    opacity: 0.4;
    cursor: default;
    box-shadow: none;
}

.btn-primary {
    background: var(--btn-primary-bg);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.45);
}

.btn-primary:hover:not(:disabled) {
    background: var(--btn-primary-bg-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--btn-secondary-bg);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--btn-secondary-bg-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--btn-ghost-bg-hover);
}

.btn-icon {
    padding: 4px 10px;
    font-size: 14px;
    line-height: 1;
    background: #111827;
    color: var(--text-main);
    border-radius: 999px;
}

.btn-icon:hover:not(:disabled) {
    background: #1f2937;
}

.segments-actions {
    margin-top: 10px;
}

/* Блоки управления и ошибок */

.controls-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
    margin-top: 4px;
}

.controls-row .btn {
    flex: 1;
}

.alert {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: var(--border-radius-md);
    font-size: 12px;
}

.alert-error {
    background: rgba(127, 29, 29, 0.25);
    color: var(--text-danger);
    border: 1px solid rgba(248, 113, 113, 0.6);
}

/* Результаты */

.result-main {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.result-block {
    flex: 1 1 180px;
    background: rgba(15, 23, 42, 0.9);
    border-radius: var(--border-radius-md);
    padding: 10px 12px;
    border: 1px solid rgba(55, 65, 81, 0.9);
}

.result-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.result-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
}

.result-sub {
    margin-top: 2px;
    font-size: 11px;
    color: var(--text-muted);
}

.result-meta {
    margin-top: 10px;
    font-size: 11px;
    color: var(--text-muted);
}

/* Инпуты в таблице */

.segments-table input.field-input {
    width: 100%;
    min-width: 70px;
}

/* Медиа-адаптация */

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

    .page-main > #segments-section,
    .page-main > #result-section {
        grid-column: 1 / 2;
    }

    .card {
        padding: 12px 12px 14px;
    }

    .title {
        font-size: 20px;
    }

    .subtitle {
        font-size: 12px;
    }
}

@media (max-width: 640px) {
    .segments-table-wrapper {
        max-height: 260px;
    }

    .segments-table th:nth-child(1),
    .segments-table td:nth-child(1) {
        width: 20px;
    }

    .segments-table th:nth-child(5),
    .segments-table td:nth-child(5) {
        width: 70px;
    }

    .controls-row {
        flex-direction: column;
    }

    .page-root {
        padding-inline: 10px;
    }
}

.wind-legend {
    margin-top: 4px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.wind-legend-image {
    max-width: 220px;
    width: 100%;
    border-radius: 8px;
    border: 1px solid rgba(55, 65, 81, 0.9);
    background: #020617;
    /* гифка маленькая по исходному размеру — чуть «пикселизуем», чтобы не была мыльной */
    image-rendering: pixelated;
}

.wind-legend-caption {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

@media (max-width: 640px) {
    .wind-legend-image {
        max-width: 170px;
    }
}

