:root {
    --bg: #eef2f6;
    --surface: #ffffff;
    --surface-soft: #f7fafc;
    --text: #17202a;
    --muted: #607080;
    --line: #dce3ea;
    --brand: #0f766e;
    --brand-dark: #115e59;
    --danger: #b42318;
    --warning: #b54708;
    --success: #067647;
    --shadow: 0 20px 45px rgba(23, 32, 42, 0.10);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    background:
        linear-gradient(135deg, rgba(15, 118, 110, 0.14), transparent 34%),
        linear-gradient(315deg, rgba(180, 83, 9, 0.10), transparent 28%),
        var(--bg);
}

.shell {
    width: min(1380px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--brand-dark);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: clamp(28px, 5vw, 46px);
}

h2 {
    font-size: 22px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
}

.status-pill.online {
    color: var(--success);
}

.status-pill.loading {
    color: var(--warning);
}

.status-pill.offline {
    color: var(--danger);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.insights-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
    gap: 14px;
    margin-bottom: 18px;
}

.metric {
    min-height: 130px;
    padding: 18px;
    border: 1px solid rgba(220, 227, 234, 0.9);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--shadow);
}

.metric-label,
.metric-unit {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.metric strong {
    display: block;
    margin: 12px 0 4px;
    font-size: 34px;
    line-height: 1;
}

.panel {
    border: 1px solid rgba(220, 227, 234, 0.95);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    border-bottom: 1px solid var(--line);
}

.panel-header.compact {
    padding-bottom: 12px;
}

.panel-header p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.toolbar label {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

select,
input,
button {
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 700;
}

select {
    padding: 0 10px;
}

input {
    width: min(300px, 100%);
    padding: 0 12px;
    font-weight: 600;
}

.search-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

button {
    padding: 0 14px;
    border-color: var(--brand);
    background: var(--brand);
    color: white;
    cursor: pointer;
}

.ghost-button {
    border-color: var(--line);
    background: var(--surface);
    color: var(--brand-dark);
}

button:disabled {
    cursor: wait;
    opacity: 0.72;
}

.chart-panel {
    min-height: 360px;
}

.chart-wrap {
    height: 260px;
    padding: 8px 14px 2px;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.legend,
.stats-row {
    display: flex;
    gap: 16px;
    padding: 0 18px 18px;
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.legend i {
    width: 22px;
    height: 4px;
    border-radius: 999px;
}

.legend-temp {
    background: #d92d20;
}

.legend-humidity {
    background: #2563eb;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.stats-row div {
    min-width: 0;
}

.stats-row span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.stats-row strong {
    display: block;
    margin-top: 5px;
    font-size: 24px;
}

.alert {
    margin: 16px 18px 0;
    padding: 12px 14px;
    border: 1px solid #fecdca;
    border-radius: 8px;
    background: #fffbfa;
    color: var(--danger);
    font-weight: 700;
}

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

table {
    width: 100%;
    min-width: 1120px;
    border-collapse: collapse;
}

th,
td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

th:last-child,
td:last-child {
    min-width: 190px;
}

th {
    background: var(--surface-soft);
    color: #314253;
    font-size: 12px;
    text-transform: uppercase;
}

tbody tr:hover {
    background: #f8fbfd;
}

.noise-badge,
.light-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
}

.noise-low {
    background: #ecfdf3;
    color: var(--success);
}

.noise-medium {
    background: #fffaeb;
    color: var(--warning);
}

.noise-high {
    background: #fef3f2;
    color: var(--danger);
}

.light-on {
    background: #fffaeb;
    color: #b54708;
}

.light-shadow {
    background: #eff8ff;
    color: #175cd3;
}

.light-dark {
    background: #f2f4f7;
    color: #344054;
}

.empty {
    padding: 34px 14px;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 820px) {
    .topbar,
    .panel-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .insights-grid {
        grid-template-columns: 1fr;
    }

    .toolbar {
        width: 100%;
        flex-wrap: wrap;
    }

    input {
        width: 100%;
    }

    .search-control {
        width: 100%;
    }
}

@media (max-width: 520px) {
    .shell {
        width: min(100% - 20px, 1180px);
        padding-top: 18px;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .metric {
        min-height: 112px;
    }

    .toolbar select,
    .toolbar input,
    .toolbar button {
        flex: 1;
        min-width: 140px;
    }
}
