.pd-widget-stack {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 45;
    width: min(326px, calc(100vw - 24px));
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: rgba(236, 253, 255, 0.92);
    font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    pointer-events: none;
}

.pd-widget-panel {
    pointer-events: auto;
    border: 1px solid rgba(91, 219, 225, 0.24);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(8, 17, 28, 0.78), rgba(4, 9, 16, 0.66)),
        repeating-linear-gradient(90deg, rgba(91, 219, 225, 0.05) 0 1px, transparent 1px 34px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28), inset 0 0 28px rgba(38, 198, 218, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    overflow: hidden;
}

.pd-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 30px;
    padding: 7px 9px 5px;
    border-bottom: 1px solid rgba(91, 219, 225, 0.14);
}

.pd-widget-title {
    margin: 0;
    color: rgba(232, 253, 255, 0.9);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.pd-widget-code {
    color: rgba(144, 235, 241, 0.72);
    font-size: 10px;
    font-family: "Consolas", "SFMono-Regular", monospace;
    letter-spacing: 0.08em;
}

.pd-widget-message {
    min-height: 42px;
}

.pd-message-screen {
    position: relative;
    min-height: 40px;
    padding: 8px 10px 10px;
    overflow: hidden;
}

.pd-message-line {
    display: block;
    color: rgba(226, 250, 252, 0.82);
    font-size: 12px;
    line-height: 1.45;
    transform: translateY(0);
    opacity: 1;
}

.pd-message-line.is-exiting {
    animation: pd-message-exit 0.28s ease forwards;
}

.pd-message-line.is-entering {
    animation: pd-message-enter 0.34s ease forwards;
}

.pd-monitor-grid {
    display: grid;
    gap: 6px;
    padding: 8px;
}

.pd-metric {
    display: grid;
    grid-template-columns: 56px 1fr 18px;
    gap: 7px;
    align-items: center;
    min-height: 34px;
    padding: 5px 6px;
    border: 0;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.035);
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.pd-metric:hover,
.pd-metric:focus-visible {
    background: rgba(91, 219, 225, 0.09);
    outline: 1px solid rgba(91, 219, 225, 0.34);
}

.pd-metric-name {
    min-width: 0;
}

.pd-metric-label {
    display: block;
    color: rgba(237, 254, 255, 0.9);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pd-metric-unit {
    display: block;
    margin-top: 2px;
    color: rgba(181, 227, 231, 0.52);
    font-size: 9px;
    line-height: 1;
    white-space: nowrap;
}

.pd-mini-chart {
    width: 100%;
    height: 28px;
    display: block;
}

.pd-mini-zone-safe {
    fill: rgba(47, 210, 119, 0.16);
}

.pd-mini-zone-watch {
    fill: rgba(241, 196, 15, 0.15);
}

.pd-mini-zone-caution {
    fill: rgba(230, 126, 34, 0.16);
}

.pd-mini-zone-alert {
    fill: rgba(231, 76, 60, 0.16);
}

.pd-mini-gridline {
    stroke: rgba(235, 255, 255, 0.1);
    stroke-width: 0.6;
}

.pd-mini-path {
    fill: none;
    stroke: rgba(216, 254, 255, 0.88);
    stroke-width: 1.4;
    vector-effect: non-scaling-stroke;
    filter: drop-shadow(0 0 3px rgba(125, 249, 255, 0.45));
}

.pd-text-readout {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 4px;
    min-width: 0;
    font-family: "Consolas", "SFMono-Regular", monospace;
}

.pd-text-value {
    color: rgba(237, 254, 255, 0.95);
    font-size: 18px;
    line-height: 1;
}

.pd-text-unit {
    color: rgba(181, 227, 231, 0.56);
    font-size: 9px;
}

.pd-status-light {
    width: 10px;
    height: 10px;
    justify-self: center;
    border-radius: 50%;
    background: var(--pd-light, #2fd277);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08), 0 0 10px var(--pd-light, #2fd277);
}

.pd-status-safe {
    --pd-light: #2fd277;
}

.pd-status-watch {
    --pd-light: #f1c40f;
}

.pd-status-caution {
    --pd-light: #e67e22;
}

.pd-status-alert {
    --pd-light: #e74c3c;
}

.pd-widget-modal {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(2, 8, 15, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.pd-widget-modal.is-open {
    display: flex;
}

.pd-widget-dialog {
    width: min(760px, 96vw);
    border: 1px solid rgba(91, 219, 225, 0.28);
    border-radius: 8px;
    background: rgba(7, 15, 26, 0.96);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.46);
    color: rgba(236, 253, 255, 0.94);
}

.pd-dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid rgba(91, 219, 225, 0.16);
}

.pd-dialog-title {
    margin: 0 0 6px;
    font-size: 18px;
    color: #f1feff;
}

.pd-dialog-value {
    color: rgba(155, 242, 247, 0.72);
    font-size: 12px;
    font-family: "Consolas", "SFMono-Regular", monospace;
}

.pd-dialog-close {
    width: 32px;
    height: 32px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(236, 253, 255, 0.9);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

.pd-dialog-body {
    padding: 16px 18px 18px;
}

.pd-full-chart {
    width: 100%;
    height: auto;
    display: block;
}

.pd-axis-text {
    fill: rgba(204, 236, 238, 0.64);
    font-size: 10px;
    font-family: "Consolas", "SFMono-Regular", monospace;
}

.pd-axis-line {
    stroke: rgba(204, 236, 238, 0.22);
    stroke-width: 1;
}

.pd-zone-label {
    fill: rgba(236, 253, 255, 0.46);
    font-size: 10px;
    font-weight: 700;
}

@keyframes pd-message-exit {
    to {
        transform: translateY(-110%);
        opacity: 0;
    }
}

@keyframes pd-message-enter {
    from {
        transform: translateY(110%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@media (max-width: 640px) {
    .pd-widget-stack {
        right: 10px;
        bottom: 10px;
        width: min(300px, calc(100vw - 20px));
    }

    .pd-widget-panel {
        background: rgba(5, 12, 20, 0.74);
    }

    .pd-metric {
        grid-template-columns: 50px 1fr 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pd-message-line.is-exiting,
    .pd-message-line.is-entering {
        animation: none !important;
    }
}
