.telemetry-dashboard-shell {
    position: fixed;
    z-index: 1650;
    top: clamp(92px, 14dvh, 126px);
    right: max(76px, calc(env(safe-area-inset-right, 0px) + 76px));
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.telemetry-dashboard-toggle {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    padding: 11px;
    border: 1px solid rgba(4, 120, 87, .28);
    border-radius: 15px;
    color: #fff;
    background: linear-gradient(145deg, #047857, #0891b2);
    box-shadow: 0 11px 28px rgba(3, 75, 83, .28);
    cursor: pointer;
    pointer-events: auto;
    transition: transform .18s ease, box-shadow .18s ease;
}

.telemetry-dashboard-toggle:hover,
.telemetry-dashboard-toggle:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 14px 32px rgba(3, 75, 83, .34);
    outline: none;
}

.telemetry-dashboard-toggle svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.telemetry-dashboard-panel {
    width: min(410px, calc(100vw - 170px));
    max-height: min(70dvh, 680px);
    margin-top: 9px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, .46);
    border-radius: 18px;
    opacity: 0;
    color: #0f172a;
    background: rgba(255, 255, 255, .985);
    box-shadow: 0 24px 62px rgba(15, 23, 42, .26);
    transform: translateY(-8px) scale(.985);
    transform-origin: top right;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease, visibility .18s;
}

.telemetry-dashboard-shell.is-open .telemetry-dashboard-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
    pointer-events: auto;
}

.telemetry-dashboard-panel > header {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 16px;
    border-bottom: 1px solid #dbe5ec;
    background: linear-gradient(135deg, #ecfdf5, #ecfeff);
}

.telemetry-dashboard-panel h2 {
    margin: 0;
    color: #075985;
    font-size: 14px;
    font-weight: 850;
    letter-spacing: .01em;
}

.telemetry-dashboard-refresh {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    padding: 7px;
    border: 1px solid #bae6fd;
    border-radius: 10px;
    color: #0369a1;
    background: #fff;
    cursor: pointer;
}

.telemetry-dashboard-refresh:hover,
.telemetry-dashboard-refresh:focus-visible {
    border-color: #38bdf8;
    background: #f0f9ff;
    outline: none;
}

.telemetry-dashboard-refresh:disabled { cursor: wait; opacity: .72; }
.telemetry-dashboard-refresh svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.telemetry-dashboard-refresh.is-loading svg { animation: telemetryDashboardSpin .8s linear infinite; }

.telemetry-dashboard-list {
    max-height: calc(min(70dvh, 680px) - 48px);
    overflow: auto;
    padding: 10px;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.telemetry-dashboard-row {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    padding: 9px;
    border: 1px solid color-mix(in srgb, var(--telemetry-accent, #16a34a) 34%, #dbe5ec);
    border-left: 5px solid var(--telemetry-accent, #16a34a);
    border-radius: 13px;
    background: color-mix(in srgb, var(--telemetry-accent, #16a34a) 4%, #fff);
}

.telemetry-dashboard-row + .telemetry-dashboard-row { margin-top: 8px; }

.telemetry-dashboard-row.is-offline {
    background: color-mix(in srgb, var(--telemetry-accent, #16a34a) 2%, #fffafa);
}

.telemetry-dashboard-photo-stack {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.telemetry-dashboard-photo {
    position: relative;
    width: 100%;
    min-height: 0;
    aspect-ratio: var(--telemetry-photo-ratio, 4 / 3);
    align-self: start;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--telemetry-accent, #16a34a) 30%, #dbe5ec);
    border-radius: 10px;
    background: color-mix(in srgb, var(--telemetry-accent, #16a34a) 9%, #f8fafc);
}

.telemetry-dashboard-photo img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

.telemetry-dashboard-photo > span {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: grid;
    place-items: center;
    color: color-mix(in srgb, var(--telemetry-accent, #16a34a) 58%, #64748b);
    font-size: 24px;
}

.telemetry-dashboard-photo img { position: relative; z-index: 1; }
.telemetry-dashboard-photo.is-missing img { display: none; }

.telemetry-dashboard-station-indicator-slot {
    width: 100%;
}

.telemetry-dashboard-station-indicator-slot:empty {
    display: none;
}

.telemetry-dashboard-weather {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 22px;
    margin-top: 4px;
    color: #64748b;
}

.telemetry-dashboard-weather-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.telemetry-dashboard-weather svg,
.telemetry-dashboard-weather .bws-weather-icon-svg {
    width: 25px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.telemetry-dashboard-weather-label {
    max-width: 78px;
    overflow: hidden;
    color: currentColor;
    font-size: 8px;
    font-weight: 800;
    line-height: 1.05;
    text-align: center;
    text-overflow: clip;
    white-space: normal;
}

.telemetry-dashboard-weather.is-dry,
.telemetry-dashboard-weather.is-cloud { color: #64748b; }
.telemetry-dashboard-weather.is-light { color: #38bdf8; }
.telemetry-dashboard-weather.is-moderate { color: #0ea5e9; }
.telemetry-dashboard-weather.is-heavy { color: #0284c7; }
.telemetry-dashboard-weather.is-very-heavy { color: #1d4ed8; }
.telemetry-dashboard-weather.is-unknown { color: #94a3b8; opacity: .72; }
.telemetry-dashboard-weather-drops,
.telemetry-dashboard-weather .bws-weather-drop { stroke-width: 1.6; }

.telemetry-dashboard-station-indicator.is-tma {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 22px;
    margin-top: 4px;
    color: #2563eb;
}

.telemetry-dashboard-station-indicator-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.telemetry-dashboard-tma-icon-svg {
    width: 25px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.telemetry-dashboard-station-indicator-label {
    max-width: 78px;
    overflow: hidden;
    color: currentColor;
    font-size: 8px;
    font-weight: 800;
    line-height: 1.05;
    text-align: center;
    text-overflow: clip;
    white-space: normal;
}

.telemetry-dashboard-content { min-width: 0; }

.telemetry-dashboard-row-head,
.telemetry-dashboard-datetime,
.telemetry-dashboard-metrics,
.telemetry-dashboard-name {
    display: flex;
    align-items: center;
}

.telemetry-dashboard-row-head {
    justify-content: space-between;
    gap: 10px;
}

.telemetry-dashboard-name {
    min-width: 0;
    gap: 6px;
}

.telemetry-dashboard-name img {
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
    object-fit: contain;
}

.telemetry-dashboard-station-icon {
    display: inline-flex;
    flex: 0 0 15px;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    color: #dc2626;
    line-height: 0;
}

.telemetry-dashboard-station-icon-svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.55;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.telemetry-dashboard-station-icon.is-aws { color: #dc2626; }

.telemetry-dashboard-name > strong {
    min-width: 0;
    overflow: hidden;
    color: #183b56;
    font-size: 11px;
    font-weight: 850;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.telemetry-dashboard-type {
    margin-top: 3px;
    color: var(--telemetry-accent, #16a34a);
    font-size: 8px;
    font-weight: 850;
}

.telemetry-dashboard-state {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 5px;
    font-size: 9px;
    font-weight: 850;
}

.telemetry-dashboard-state i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 13%, transparent);
}

.telemetry-dashboard-state.is-online { color: #16a34a; }
.telemetry-dashboard-state.is-offline { color: #dc2626; }

.telemetry-dashboard-datetime {
    gap: 9px;
    margin-top: 6px;
    color: #64748b;
    font-size: 9px;
    font-weight: 700;
}

.telemetry-dashboard-datetime time + time {
    padding-left: 9px;
    border-left: 1px solid #dbe5ec;
}

.telemetry-dashboard-metrics {
    gap: 7px;
    flex-wrap: wrap;
    margin-top: 9px;
}

.telemetry-dashboard-metrics.is-climate {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
    align-items: stretch;
}

.telemetry-dashboard-metrics > div {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    padding: 8px 9px;
    border-radius: 9px;
    background: color-mix(in srgb, var(--telemetry-accent, #16a34a) 8%, #f8fafc);
}

.telemetry-dashboard-metrics span,
.telemetry-dashboard-metrics b { display: block; }

.telemetry-dashboard-metrics span {
    color: #64748b;
    font-size: 8px;
    font-weight: 750;
}

.telemetry-dashboard-metrics b {
    margin-top: 3px;
    color: color-mix(in srgb, var(--telemetry-accent, #16a34a) 72%, #0f172a);
    font-size: 13px;
    font-weight: 850;
}

.telemetry-dashboard-metrics small {
    font-size: 8px;
    font-weight: 800;
}

.telemetry-dashboard-metrics.is-climate > div {
    width: auto;
    min-width: 0;
    min-height: 55px;
    display: grid;
    grid-template-columns: 19px minmax(0, 1fr);
    column-gap: 6px;
    align-items: center;
}

.telemetry-dashboard-aws-parameter-icon {
    display: inline-flex !important;
    grid-column: 1;
    grid-row: 1 / span 2;
    align-items: center;
    justify-content: center;
    width: 19px;
    height: 25px;
    color: var(--telemetry-accent, #ef4444);
    line-height: 0;
}

.telemetry-dashboard-aws-icon-svg,
.telemetry-dashboard-aws-parameter-icon .bws-weather-icon-svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.65;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.telemetry-dashboard-aws-label {
    grid-column: 2;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.telemetry-dashboard-metrics.is-climate > div > b {
    grid-column: 2;
    margin-top: 2px;
}

.telemetry-dashboard-aws-empty {
    grid-column: 1 / -1;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 42px;
    color: #64748b;
}

.telemetry-dashboard-aws-empty b {
    margin-top: 0;
    color: #94a3b8;
    font-size: 10px;
    font-weight: 750;
}

.telemetry-dashboard-aws-parameter-icon.is-temperature { color: #dc2626; }
.telemetry-dashboard-aws-parameter-icon.is-humidity,
.telemetry-dashboard-aws-parameter-icon.is-rain { color: #0284c7; }
.telemetry-dashboard-aws-parameter-icon.is-wind,
.telemetry-dashboard-aws-parameter-icon.is-direction { color: #0891b2; }
.telemetry-dashboard-aws-parameter-icon.is-pressure { color: #7c3aed; }
.telemetry-dashboard-aws-parameter-icon.is-solar { color: #d97706; }
.telemetry-dashboard-aws-parameter-icon.is-evaporation { color: #0f766e; }

.telemetry-dashboard-loading,
.telemetry-dashboard-empty {
    min-height: 96px;
    display: grid;
    place-items: center;
    color: #64748b;
    font-size: 10px;
    font-weight: 750;
}

.telemetry-dashboard-loading i {
    width: 22px;
    height: 22px;
    border: 3px solid #bae6fd;
    border-top-color: #0284c7;
    border-radius: 50%;
    animation: telemetryDashboardSpin .8s linear infinite;
}

.telemetry-dashboard-empty.is-error { color: #b91c1c; }

@keyframes telemetryDashboardSpin { to { transform: rotate(360deg); } }

@media (max-width: 620px) {
    .telemetry-dashboard-shell {
        top: max(86px, calc(env(safe-area-inset-top, 0px) + 70px));
        right: max(72px, calc(env(safe-area-inset-right, 0px) + 72px));
    }
    .telemetry-dashboard-shell.is-open {
        right: max(10px, env(safe-area-inset-right, 0px));
    }
    .telemetry-dashboard-toggle {
        width: 46px;
        height: 46px;
        border-radius: 14px;
    }
    .telemetry-dashboard-panel {
        width: calc(100vw - 20px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
        max-height: calc(var(--bws-visible-height, 100dvh) - 178px - env(safe-area-inset-bottom, 0px));
    }
    .telemetry-dashboard-list {
        max-height: calc(var(--bws-visible-height, 100dvh) - 226px - env(safe-area-inset-bottom, 0px));
    }
    .telemetry-dashboard-row { grid-template-columns: 76px minmax(0, 1fr); }
}

@media (max-width: 370px) {
    .telemetry-dashboard-row { grid-template-columns: 68px minmax(0, 1fr); }
    .telemetry-dashboard-metrics:not(.is-climate) { display: grid; grid-template-columns: 1fr; }
    .telemetry-dashboard-metrics.is-climate { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
    .telemetry-dashboard-toggle,
    .telemetry-dashboard-panel { transition: none; }
}
