* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f4f5f7;
    color: #111;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: #111;
    margin-bottom: 24px;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 6px;
    font-weight: 600;
}

.mode-switcher {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 20px;
}

.mode-btn {
    padding: 8px 18px;
    border: 1px solid #d0d0d0;
    border-radius: 999px;
    font-size: 0.95em;
    cursor: pointer;
    transition: background 0.12s ease;
    font-weight: 600;
    background: #ffffff;
    color: #111;
}

.mode-btn.active {
    background: #111;
    color: #fff;
    border-color: #111;
}

.mode-btn:hover {
    background: #f0f0f0;
}

.mode-content {
    display: none;
}

.mode-content.active {
    display: block;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.status-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 14px;
    border: 1px solid #e6e6e6;
    box-shadow: 0 4px 12px rgba(17, 17, 17, 0.04);
    cursor: pointer;
}

.status-card:hover {
    border-color: #bdbdbd;
}

.status-card.compass-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.status-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.status-card h3 {
    color: #222;
    font-size: 0.95em;
    margin-bottom: 2px;
}

.status-card p {
    color: #666;
    font-size: 0.82em;
}

.status-card-hint {
    font-size: 0.72em;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-value {
    font-size: 1.7em;
    font-weight: 700;
    color: #111;
}

.status-unit {
    color: #666;
    font-size: 0.85em;
    margin-bottom: 6px;
}

.wind-compass {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin: 8px 0 10px;
}

.wind-compass-face {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 2px solid #111;
    background: linear-gradient(135deg, #f8f8f8, #ececec);
}

.wind-compass-face::before {
    content: '';
    position: absolute;
    inset: 10px;
    border-radius: 50%;
    border: 1px dashed #bbb;
}

.wind-compass-needle {
    position: absolute;
    inset: 0;
    transform-origin: center;
}

.wind-compass-needle::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 4px;
    height: 30px;
    background: #111;
    border-radius: 2px;
    transform: translate(-50%, -50%);
}

.wind-compass-needle::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 10px;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 12px solid #e74c3c;
    transform: translateX(-50%);
}

.wind-compass-label-n,
.wind-compass-label-e,
.wind-compass-label-s,
.wind-compass-label-w {
    position: absolute;
    font-size: 0.7em;
    font-weight: 700;
    color: #444;
}

.wind-compass-label-n { top: 4px; left: 50%; transform: translateX(-50%); }
.wind-compass-label-e { right: 4px; top: 50%; transform: translateY(-50%); }
.wind-compass-label-s { bottom: 4px; left: 50%; transform: translateX(-50%); }
.wind-compass-label-w { left: 4px; top: 50%; transform: translateY(-50%); }

.wind-compass-value {
    font-size: 0.8em;
    font-weight: 600;
    color: #333;
}

.status-pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.group-pill {
    border: 1px solid #ddd;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 0.74em;
    background: #f8f8f8;
    color: #333;
    cursor: pointer;
}

.group-pill.active {
    background: #111;
    border-color: #111;
    color: #fff;
}

.status-chart-wrap {
    height: 90px;
}

.monitoring-panels {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 20px;
    margin-bottom: 24px;
}

.monitoring-panel {
    min-width: 0;
}

.panel-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.panel-header h2 {
    font-size: 1.1em;
}

.panel-header label {
    font-size: 0.9em;
    color: #555;
}

.panel-header select {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.chart-container {
    background: #ffffff;
    border-radius: 16px;
    padding: 12px;
    border: 1px solid #e6e6e6;
    box-shadow: 0 4px 12px rgba(17, 17, 17, 0.04);
    min-height: 150px;
}

.chart-container h3 {
    color: #333;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.chart-container canvas {
    width: 100% !important;
    height: 140px !important;
    max-height: 140px;
}

.custom-plot-section {
    background: #ffffff;
    border-radius: 16px;
    padding: 16px;
    border: 1px solid #e6e6e6;
    box-shadow: 0 4px 12px rgba(17, 17, 17, 0.04);
}

.custom-plot-section h2 {
    color: #111;
    margin-bottom: 12px;
}

.variable-select {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.variable-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.variable-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.variable-group label {
    margin: 0;
    cursor: pointer;
    flex: 1;
    font-size: 0.95em;
}

.button-group {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.btn {
    padding: 8px 16px;
    border: 1px solid #bfbfbf;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 700;
    transition: background 0.12s ease;
    background: #111;
    color: #fff;
}

.btn:hover {
    background: #222;
}

.btn.secondary {
    background: #f5f5f5;
    color: #111;
    border-color: #ddd;
}

.btn.secondary:hover {
    background: #ededed;
}

.compact-chart {
    margin-top: 12px;
    min-height: 220px;
}

.analysis-controls {
    background: #ffffff;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(17, 17, 17, 0.04);
    border: 1px solid #e6e6e6;
}

.control-group {
    margin-bottom: 14px;
}

.control-group label {
    display: block;
    color: #333;
    font-weight: 600;
    margin-bottom: 6px;
}

.control-group input,
.control-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 0.95em;
}

.control-group input:focus,
.control-group select:focus {
    outline: none;
    border-color: #999;
    box-shadow: none;
}

.controls-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.summaries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.summary-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(17, 17, 17, 0.04);
    border: 1px solid #e6e6e6;
}

.summary-card h3 {
    color: #111;
    margin-bottom: 10px;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
}

.summary-table th {
    background: #fafafa;
    color: #111;
    padding: 8px;
    text-align: left;
    font-weight: 700;
    border-bottom: 1px solid #eee;
}

.summary-table td {
    padding: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.summary-table tr:last-child td {
    border-bottom: none;
}

.loading {
    text-align: center;
    color: #555;
    font-size: 1em;
}

.error {
    background: #ffecec;
    color: #b00020;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 12px;
    border: 1px solid #f5c6cb;
}

@media (min-width: 1280px) {
    .status-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 960px) {
    .monitoring-panels {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    body {
        padding: 12px;
    }

    .status-grid,
    .charts-grid,
    .summaries-grid {
        grid-template-columns: 1fr;
    }
}