* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: #1a1a2e;
    min-height: 100vh;
    padding: 10px;
    color: #333;
    overflow: hidden;
}

.container {
    display: flex;
    width: 100%;
    height: calc(100vh - 20px);
    gap: 10px;
}

.map-section {
    flex: 1 1 0;
    min-width: 0;
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    position: relative;
}

#map {
    height: 100%;
    width: 100%;
}

.map-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.map-controls select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    width: 180px;
}

.overlay-controls {
    position: absolute;
    top: 10px;
    right: 250px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    width: 320px;
}

.overlay-control {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.overlay-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.overlay-label {
    font-size: 0.9rem;
    color: #333;
    user-select: none;
}

.data-section {
    flex: 0 1 clamp(300px, 38vw, 720px);
    min-width: 300px;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.weather-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 5px;
    text-align: center;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.weather-header h2 {
    font-size: 1.2rem;
    margin-bottom: 5px;
}

.coordinates-display {
    font-family: monospace;
    background: rgba(255, 255, 255, 0.1);
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.85rem;
    display: inline-block;
}

.datetime-controls {
    padding: 5px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.date-input {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.weather-preview-btn {
    flex: 0 0 auto;
    padding: 5px 12px;
    font-size: 13px;
}

.date-input input {
    flex: 1;
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 13px;
    min-width: 120px;
}

.time-slider-container {
    position: relative;
    align-items: center;
}

.time-display {
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.time-slider {
    width: 100%;
    height: 24px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #4facfe, #00f2fe);
    outline: none;
    border-radius: 12px;
}

.time-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #764ba2;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

.time-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #764ba2;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

.grid-controls {
    padding: 5px 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #eaeaea;
    min-height: 70px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.grid-input-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

.grid-input-label {
    font-size: 0.85rem;
    color: #333;
    white-space: nowrap;
}

.grid-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9rem;
    max-width: fit-content;
}

.grid-button {
    padding: 6px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.grid-button:hover {
    opacity: 0.9;
}

.grid-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.grid-status {
    font-size: 0.8rem;
    color: #666;
    text-align: center;
    margin-top: 2px;
}

.grid-warning {
    font-size: 0.8rem;
    color: #e74c3c;
    text-align: center;
    margin-top: 2px;
    display: none;
}

.weather-data {
    flex: 1;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    min-height: 0;
}

.weather-preview-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    flex: 1;
}

.weather-preview-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.weather-preview-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
}

.weather-preview-period {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.weather-preview-period input[type="date"] {
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 13px;
}

.weather-preview-shift-btn {
    flex: 0 0 auto;
    min-width: 34px;
    padding: 4px 10px;
    font-size: 14px;
    font-weight: 600;
}

.weather-preview-range-sep {
    color: #888;
}

.weather-preview-chart {
    flex: 1;
    min-height: 300px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    padding: 8px;
}

.weather-preview-placeholder,
.weather-preview-chart .loading,
.weather-preview-chart .error {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 260px;
    color: #666;
    text-align: center;
    padding: 12px;
}

.weather-preview-meta {
    font-size: 0.75rem;
    color: #777;
    line-height: 1.35;
}

.weather-preview-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    font-size: 0.75rem;
    color: #444;
    margin-bottom: 4px;
}

.preview-swatch {
    display: inline-block;
    width: 12px;
    height: 3px;
    margin-right: 5px;
    vertical-align: middle;
    border-radius: 1px;
}

.preview-swatch-temp { background: #f0a04b; }
.preview-swatch-dew { background: #7ec8e3; }
.preview-swatch-cloud { background: #9ca3af; }
.preview-swatch-rain {
    width: 8px;
    height: 10px;
    background: #2563eb;
}

.weather-preview-svg-wrap {
    position: relative;
    width: 100%;
}

.preview-grid {
    stroke: #e8e8e8;
    stroke-width: 1;
}

.preview-line {
    stroke-width: 1.6;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.preview-line-temp { stroke: #f0a04b; }
.preview-line-dew { stroke: #7ec8e3; }
.preview-line-cloud { stroke: #9ca3af; }

.preview-rain-bar {
    fill: rgba(37, 99, 235, 0.55);
}

.preview-axis-label {
    font-size: 10px;
    fill: #666;
}

.preview-axis-title {
    font-size: 10px;
    fill: #888;
}

.preview-axis-temp { fill: #d4892e; }
.preview-axis-cloud { fill: #6b7280; }
.preview-axis-rain { fill: #2563eb; }

.preview-crosshair {
    stroke: #999;
    stroke-width: 1;
    pointer-events: none;
}

.preview-dot {
    stroke: #fff;
    stroke-width: 1;
    pointer-events: none;
}

.preview-dot-temp { fill: #f0a04b; }
.preview-dot-dew { fill: #7ec8e3; }
.preview-dot-cloud { fill: #9ca3af; }
.preview-dot-rain { fill: #2563eb; }

.preview-hover-time {
    position: absolute;
    bottom: 0;
    transform: translateX(-50%);
    background: #6b7280;
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 2;
}

.preview-hover-tips {
    position: absolute;
    top: 28px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: none;
    z-index: 2;
    max-width: 90%;
}

.preview-hover-tips-right {
    transform: translateX(8px);
}

.preview-hover-tips-left {
    transform: translateX(calc(-100% - 8px));
}

.preview-tip {
    background: #fff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 0.72rem;
    color: #333;
    white-space: nowrap;
}

.preview-tip span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.preview-tip-cloud span { background: #9ca3af; }
.preview-tip-temp span { background: #f0a04b; }
.preview-tip-dew span { background: #7ec8e3; }
.preview-tip-rain span { background: #2563eb; }

.weather-data-row {
    display: flex;
    gap: 10px;
    min-width: 0;
}

.weather-data-row .data-card {
    flex: 1;
    min-width: 0;
}

.task-section {
    border-top: 1px solid #e5e7eb;
    padding: 12px 15px 15px;
    background: #fafafa;
    flex-shrink: 0;
}

.task-section-title {
    font-size: 0.95rem;
    margin-bottom: 10px;
    color: #333;
}

.task-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.task-controls-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.task-controls-row:last-child {
    margin-bottom: 0;
}

.task-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.task-button-weather {
    background: #c0392b;
}

.task-button {
    flex: 1;
    min-width: 120px;
}

.task-button-secondary {
    background: #95a5a6;
}

.task-button-trn {
    background: #e67e22;
}

.trn-info {
    font-size: 0.8rem;
    line-height: 1.4;
    color: #555;
    margin-bottom: 6px;
    padding: 6px 8px;
    background: rgba(230, 126, 34, 0.08);
    border-radius: 6px;
}

.trn-info-loaded {
    color: #2c3e50;
    background: rgba(46, 204, 113, 0.12);
}

.task-info {
    font-size: 0.82rem;
    line-height: 1.45;
    color: #444;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 6px;
    padding: 8px 10px;
}

.task-info-error {
    color: #c0392b;
    background: #ffeaea;
}

.data-card {
    background: white;
    border-radius: 8px;
    padding: 10px 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    border-left: 4px solid;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
}

.card-content {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.card-icon {
    font-size: 1.2rem;
    width: 30px;
    text-align: center;
}

.card-info {
    flex: 1;
    min-width: 0;
}

.card-title {
    font-size: 0.72rem;
    color: #666;
    margin-bottom: 2px;
    line-height: 1.2;
}

.card-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
    line-height: 1.2;
}

.card-details {
    font-size: 0.7rem;
    color: #888;
    margin-top: 2px;
}

.wind-card { border-left-color: #4facfe; }
.temp-card { border-left-color: #e74c3c; }
.humidity-card { border-left-color: #3498db; }
.pressure-card { border-left-color: #9b59b6; }
.cloud-card { border-left-color: #95a5a6; }
.rain-card { border-left-color: #2ecc71; }
.nko-card { border-left-color: #e67e22; }
.thermal-card { border-left-color: #f1c40f; }

.loading {
    width: 100%;
    text-align: center;
    padding: 30px;
    color: #666;
    font-style: italic;
    display: flex;
    align-items: center;
    justify-content: center;
}

.error {
    width: 100%;
    background: #ffeaea;
    color: #e74c3c;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-size: 0.9rem;
}

.status-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 0.8rem;
    z-index: 1000;
    display: none;
}

/* Оверлей маркера на карте */
.map-overlay {
    position: absolute;
    z-index: 1000;
    pointer-events: none;
    overflow: visible;
}

.wind-info,
.temp-info {
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    margin-top: 5px;
}

/* Блок ветра на одной высоте с блоком температуры (ниже линии высоты) */
.map-wind-info-wrap {
    --map-wind-info-top: 138px;
    --map-wind-info-left: 100px;
    position: absolute;
    top: var(--map-wind-info-top);
    left: var(--map-wind-info-left);
}

.map-zone-panel {
    /* Положение панели ПЗ относительно оверлея маркера */
    --map-zone-panel-top: 197px;
    --map-zone-panel-left: 40px;
    /* Ширина: два info-блока + зазор между ними */
    --map-info-box-width: 80px;
    --map-info-gap: 10px;
    position: absolute;
    top: var(--map-zone-panel-top);
    left: var(--map-zone-panel-left);
    width: calc(var(--map-info-box-width) * 2 + var(--map-info-gap));
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
}

.map-zone-panel-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.map-zone-panel-row {
    line-height: 1.35;
    white-space: nowrap;
}

.map-zone-panel-row-icons {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    min-height: 36px;
    margin-bottom: 2px;
}

.map-zone-wind {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 4px;
    /* Горизонтальное и вертикальное положение флюга ветра в строке 1 */
    --map-zone-wind-offset-x: 10px;
    --map-zone-wind-offset-y: 10px;
    margin-left: var(--map-zone-wind-offset-x);
    margin-top: var(--map-zone-wind-offset-y);
    overflow: visible;
}

.map-zone-wind-svg {
    display: block;
    overflow: visible;
    flex: 0 0 auto;
}

.map-zone-wind-speed {
    font-size: 0.8rem;
    line-height: 1;
    white-space: nowrap;
}

.map-zone-thermal {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    /* Горизонтальное положение термиков в строке 1 */
    --map-zone-thermal-offset-x: 4px;
    margin-left: var(--map-zone-thermal-offset-x);
}

.map-zone-thermal-wave {
    display: flex;
    justify-content: flex-start;
}

.map-zone-rain {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 2px;
    min-height: 24px;
    /* Горизонтальное положение дождя в строке 1 */
    --map-zone-rain-offset-x: 4px;
    margin-left: var(--map-zone-rain-offset-x);
}

.cloud-visual {
    position: relative;
    margin-top: 10px;
}

.cloud-icon-svg {
    display: block;
    width: 112px;
    height: auto;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.2));
}

.cloud-svg-text {
    fill: #e74c3c;
    font-family: sans-serif;
    font-weight: 600;
    pointer-events: none;
}

.nko-line {
    width: 2px;
    background: linear-gradient(to top, rgba(231, 126, 34, 0), rgba(231, 126, 34, 1));
    margin: 0 auto;
    position: relative;
    flex: 0 0 auto;
}

.nko-stack {
    position: absolute;
    top: 90px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.elevation-row {
    position: relative;
    align-self: stretch;
    min-height: 18px;
}

.elevation-axis {
    position: absolute;
    left: calc(50% + 1px);
    top: 0;
}

.elevation-value {
    color: #013d65;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    min-height: 1.2em;
    margin-bottom: 2px;
    white-space: nowrap;
}

.elevation-line {
    width: 48px;
    height: 2px;
    background: #000;
}

.nko-stack .temp-info {
    margin-top: 5px;
}

.map-elevation-only {
    position: absolute;
    left: 50%;
    top: 55%;
    transform: translateX(-50%);
}

.map-elevation-only .elevation-axis {
    position: relative;
    left: 0;
    top: 0;
}

.thermal-lines {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: 5px;
    align-items: center;
}

.rain-lines {
    position: absolute;
    left: 30px;
    right: 0;
    top: 80px;
    display: flex;
    justify-content: center;
    gap: 2px;
    margin-top: 5px;
}

.rain-line {
    width: 2px;
    height: 8px;
    background: #3498db;
    transform: rotate(45deg);
    opacity: 0.6;
}

/* Canvas-оверлеи на карте */
.leaflet-canvas-overlay {
    pointer-events: none;
}
.leaflet-control-attribution {
    display: block;
    font-size: 11px;
    background: rgba(255, 255, 255, 0.75);
}

.wind-barb-container {
    position: absolute;
    pointer-events: none;
    z-index: 600;
}

.wind-barb {
    position: absolute;
    transform: translate(-50%, -50%);
}

.wind-barb-svg {
    filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.3));
}

.cloud-cell {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.nko-value {
    font-size: 0.65rem;
    font-weight: bold;
    color: #333;
    text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.8);
    line-height: 1.1;
    position: relative;
}

.rain-drop {
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 0.8rem;
    color: #3498db;
    text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.8);
}

@media (max-height: 900px) {
    .weather-data {
        max-height: calc(100vh - 180px);
    }

    .data-card {
        min-height: 50px;
        padding: 8px 10px;
    }

    .card-value {
        font-size: 1rem;
    }
}
