:root {
    --bg: #09111f;
    --bg-soft: #10192c;
    --panel: rgba(10, 18, 33, 0.86);
    --line: rgba(116, 150, 215, 0.2);
    --line-strong: rgba(120, 212, 255, 0.34);
    --text-main: #eaf2ff;
    --text-sub: #9bb0cf;
    --text-soft: #7690b5;
    --cyan: #5ed4ff;
    --teal: #5df0c4;
    --red: #ff6b7c;
    --amber: #ffb14d;
    --shadow: 0 24px 80px rgba(1, 7, 18, 0.46);
    --radius-xl: 32px;
    --radius-lg: 24px;
    --radius-md: 18px;
    --font-display: "Avenir Next Condensed", "DIN Alternate", "Arial Narrow", sans-serif;
    --font-body: "Avenir Next", "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    color: var(--text-main);
    background:
        radial-gradient(circle at 12% 10%, rgba(94, 212, 255, 0.18), transparent 26%),
        radial-gradient(circle at 88% 14%, rgba(255, 177, 77, 0.16), transparent 22%),
        linear-gradient(180deg, #08101c 0%, #0c1524 48%, #0a101a 100%);
    line-height: 1.6;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 0.85), transparent 82%);
    opacity: 0.5;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

.page-shell {
    position: relative;
    z-index: 1;
    width: min(1340px, calc(100% - 32px));
    margin: 26px auto 72px;
}

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

.back-link,
.lang-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(11, 18, 32, 0.74);
    color: var(--text-sub);
    backdrop-filter: blur(14px);
}

.lang-link {
    min-width: 56px;
    font-family: var(--font-display);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-main);
}

.hero-panel,
.panel {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: linear-gradient(180deg, rgba(12, 21, 36, 0.88), rgba(8, 13, 24, 0.94));
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.hero-panel::before,
.panel::before {
    content: "";
    position: absolute;
    inset: auto auto -40% -10%;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(94, 212, 255, 0.16), transparent 68%);
    pointer-events: none;
}

.hero-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
    gap: 24px;
    padding: 34px;
}

.hero-copy,
.panel > * {
    position: relative;
    z-index: 1;
}

.hero-kicker,
.panel-kicker {
    margin: 0 0 12px;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--cyan);
}

.hero-panel h1,
.panel h2 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.02em;
}

.hero-panel h1 {
    font-size: clamp(2.2rem, 5vw, 4.1rem);
    line-height: 1;
}

.hero-desc {
    max-width: 60ch;
    margin: 18px 0 24px;
    color: var(--text-sub);
    font-size: 1rem;
}

.hero-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.hero-tags span {
    padding: 8px 12px;
    border: 1px solid rgba(94, 212, 255, 0.18);
    border-radius: 999px;
    background: rgba(11, 18, 32, 0.58);
    font-size: 0.82rem;
    color: var(--text-sub);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.metric-card {
    min-height: 154px;
    padding: 20px;
    border: 1px solid rgba(116, 150, 215, 0.16);
    border-radius: 24px;
    background:
        linear-gradient(160deg, rgba(15, 25, 42, 0.96), rgba(8, 14, 27, 0.84)),
        radial-gradient(circle at top right, rgba(94, 212, 255, 0.14), transparent 52%);
}

.metric-label {
    margin: 0 0 14px;
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-soft);
}

.metric-value {
    display: block;
    margin-bottom: 10px;
    font-family: var(--font-display);
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 0.95;
    letter-spacing: 0.04em;
}

.metric-sub {
    margin: 0;
    color: var(--text-sub);
    font-size: 0.9rem;
}

.dashboard-grid,
.monitor-grid {
    display: grid;
    gap: 18px;
    margin-top: 18px;
}

.dashboard-grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
}

.monitor-grid {
    grid-template-columns: minmax(0, 1.18fr) minmax(320px, 0.82fr);
}

.panel {
    padding: 24px;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.chart-title-wrap {
    flex: 1 1 auto;
    min-width: 0;
}

.panel h2 {
    font-size: clamp(1.45rem, 2.4vw, 2rem);
    line-height: 1.05;
}

.panel-caption {
    margin: 0;
    max-width: 28ch;
    color: var(--text-soft);
    font-size: 0.9rem;
    text-align: right;
}

.toolbar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.select-wrap {
    display: grid;
    gap: 6px;
    color: var(--text-sub);
    font-size: 0.84rem;
}

.select-wrap select {
    min-width: 180px;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid rgba(116, 150, 215, 0.22);
    border-radius: 14px;
    background: rgba(14, 24, 40, 0.88);
    color: var(--text-main);
}

.ghost-btn {
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid rgba(94, 212, 255, 0.24);
    border-radius: 14px;
    background: rgba(14, 24, 40, 0.88);
    color: var(--text-main);
    white-space: nowrap;
    cursor: pointer;
    transition: transform 0.22s ease, border-color 0.22s ease, background 0.22s ease;
}

.ghost-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(94, 212, 255, 0.42);
    background: rgba(19, 31, 52, 0.94);
}

.chart-shell {
    min-height: 300px;
    padding: 12px;
    border: 1px solid rgba(116, 150, 215, 0.14);
    border-radius: 24px;
    background:
        linear-gradient(180deg, rgba(6, 12, 23, 0.9), rgba(12, 20, 34, 0.82)),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: auto, 68px 68px, 68px 68px;
}

#temperatureChart {
    width: 100%;
    height: 280px;
    display: block;
}

.chart-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.meta-pill,
.status-card,
.device-item,
.flow-card,
.event-item,
.endpoint-card {
    border: 1px solid rgba(116, 150, 215, 0.14);
    border-radius: 18px;
    background: rgba(10, 18, 33, 0.74);
}

.meta-pill {
    padding: 16px;
}

.meta-pill span,
.status-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-soft);
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.meta-pill strong,
.status-value {
    font-family: var(--font-display);
    font-size: 1.8rem;
    letter-spacing: 0.04em;
}

.side-stack {
    display: grid;
    gap: 18px;
}

.status-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.status-card {
    padding: 16px;
}

.status-note {
    margin: 8px 0 0;
    color: var(--text-sub);
    font-size: 0.88rem;
}

.mono,
.mono-cell,
.endpoint-card code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.device-list,
.event-list {
    display: grid;
    gap: 10px;
}

.device-item {
    padding: 14px;
}

.device-item.selected {
    border-color: rgba(94, 212, 255, 0.32);
}

.device-item-head,
.event-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.device-item h3 {
    margin: 0 0 4px;
    font-size: 1rem;
}

.device-item p {
    margin: 0;
    color: var(--text-soft);
    font-size: 0.82rem;
}

.device-item-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
    color: var(--text-sub);
    font-size: 0.9rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.status-badge.online {
    background: rgba(93, 240, 196, 0.12);
    color: var(--teal);
}

.status-badge.idle {
    background: rgba(255, 177, 77, 0.14);
    color: var(--amber);
}

.spec-list {
    margin: 0;
    padding-left: 18px;
    color: var(--text-sub);
}

.spec-list li + li {
    margin-top: 10px;
}

.endpoint-card {
    margin-top: 16px;
    padding: 14px;
}

.endpoint-card span {
    display: block;
    margin-bottom: 6px;
    color: var(--text-soft);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.table-wrap {
    overflow: auto;
    border: 1px solid rgba(116, 150, 215, 0.14);
    border-radius: 18px;
    background: rgba(8, 14, 27, 0.72);
}

.history-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

.history-table th,
.history-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(116, 150, 215, 0.12);
    text-align: left;
    font-size: 0.9rem;
}

.history-table th {
    color: var(--text-soft);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.empty-row {
    text-align: center;
    color: var(--text-sub);
}

.event-item {
    padding: 14px;
}

.event-kind {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-sub);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.event-time {
    color: var(--text-soft);
    font-size: 0.8rem;
}

.event-message {
    margin: 10px 0 0;
    color: var(--text-main);
    font-size: 0.92rem;
}

.event-item.success {
    border-color: rgba(93, 240, 196, 0.20);
}

.event-item.error {
    border-color: rgba(255, 107, 124, 0.26);
}

.flow-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.flow-card {
    padding: 18px;
}

.flow-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    margin-bottom: 14px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(94, 212, 255, 0.24), rgba(93, 240, 196, 0.24));
    font-family: var(--font-display);
    font-size: 1.15rem;
    letter-spacing: 0.06em;
}

.flow-card h3 {
    margin: 0 0 8px;
    font-size: 1.04rem;
}

.flow-card p {
    margin: 0;
    color: var(--text-sub);
    font-size: 0.9rem;
}

.empty-state {
    padding: 18px;
    border: 1px dashed rgba(116, 150, 215, 0.22);
    border-radius: 18px;
    color: var(--text-sub);
    text-align: center;
    background: rgba(8, 14, 27, 0.42);
}

.footer-note {
    margin: 18px 4px 0;
    color: var(--text-soft);
    font-size: 0.84rem;
}

@media (max-width: 1120px) {
    .hero-panel,
    .dashboard-grid,
    .monitor-grid {
        grid-template-columns: 1fr;
    }

    .metrics-grid,
    .chart-meta,
    .flow-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .panel-caption {
        text-align: left;
    }
}

@media (min-width: 1121px) {
    .chart-panel-head h2 {
        white-space: nowrap;
    }
}

@media (max-width: 720px) {
    .page-shell {
        width: min(100%, calc(100% - 18px));
        margin-top: 16px;
        margin-bottom: 40px;
    }

    .hero-panel,
    .panel {
        padding: 18px;
        border-radius: 24px;
    }

    .topbar,
    .panel-head,
    .toolbar-row,
    .event-head,
    .device-item-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .metrics-grid,
    .chart-meta,
    .flow-grid,
    .device-item-metrics {
        grid-template-columns: 1fr;
    }

    .select-wrap,
    .select-wrap select,
    .ghost-btn {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
