﻿:root {
  --bg-0: #050914;
  --bg-1: #0a1328;
  --bg-2: #111b38;
  --line: rgba(124, 164, 255, 0.28);
  --line-soft: rgba(124, 164, 255, 0.16);
  --ink: #e8efff;
  --muted: #9bacd5;
  --teal: #54e4c5;
  --blue: #69a7ff;
  --amber: #f0b63f;
  --danger: #f56b6b;
  --good: #38c793;
  --neutral: #8791a8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Segoe UI", "Noto Sans TC", sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(84, 228, 197, 0.16), transparent 24%),
    radial-gradient(circle at 85% 10%, rgba(105, 167, 255, 0.18), transparent 28%),
    linear-gradient(140deg, var(--bg-0) 0%, var(--bg-1) 48%, var(--bg-2) 100%);
  min-height: 100vh;
}

.dashboard-shell,
.debug-shell {
  width: min(1240px, 94vw);
  margin: 24px auto 40px;
}

.glass-panel {
  background: linear-gradient(145deg, rgba(13, 25, 53, 0.72), rgba(9, 18, 40, 0.78));
  border: 1px solid var(--line-soft);
  box-shadow:
    0 14px 44px rgba(3, 6, 18, 0.55),
    inset 0 1px 0 rgba(178, 206, 255, 0.12);
  backdrop-filter: blur(8px);
}

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

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

.eyebrow {
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9ac4ff;
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 8px 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.14;
}

.hero-subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 760px;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-direction: column;
  min-width: 220px;
}

.status-chip {
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid rgba(84, 228, 197, 0.42);
  background: rgba(84, 228, 197, 0.14);
  color: #bdf8ec;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.status-chip-subtle {
  border-color: rgba(142, 174, 255, 0.34);
  background: rgba(142, 174, 255, 0.15);
  color: #d7e4ff;
}

.status-chip-warning {
  border-color: rgba(245, 107, 107, 0.4);
  background: rgba(245, 107, 107, 0.15);
  color: #ffd2d2;
}

.debug-link {
  text-decoration: none;
  color: #8fd6ff;
  border: 1px solid rgba(143, 214, 255, 0.32);
  border-radius: 10px;
  padding: 8px 12px;
  text-align: center;
  font-weight: 700;
}

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

h2 {
  margin: 0;
  font-size: 17px;
}

.muted {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.range-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.range-btn {
  background: rgba(138, 166, 235, 0.13);
  color: #dce8ff;
  border: 1px solid rgba(138, 166, 235, 0.25);
  border-radius: 9px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.range-btn.active {
  background: linear-gradient(120deg, rgba(84, 228, 197, 0.22), rgba(105, 167, 255, 0.35));
  border-color: rgba(169, 227, 255, 0.65);
  color: #f1ffff;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric-card {
  min-height: 108px;
  position: relative;
  overflow: hidden;
}

.metric-card::after {
  content: "";
  position: absolute;
  inset: auto -20px -32px auto;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(84, 228, 197, 0.25), transparent 70%);
  pointer-events: none;
}

.metric-title {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.metric-main {
  margin: 10px 0 0;
  font-size: clamp(22px, 2.3vw, 30px);
  font-weight: 800;
  line-height: 1.15;
}

.metric-time {
  font-size: 15px;
  font-weight: 700;
}

.unit {
  font-size: 14px;
  margin-left: 6px;
  color: #9cc5ff;
}

.online {
  color: #7ef8ca;
}

.offline {
  color: #ff9797;
}

.main-grid {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

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

.status-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid rgba(151, 170, 210, 0.4);
  background: rgba(151, 170, 210, 0.16);
  color: #d7deef;
}

.badge-warn {
  background: rgba(240, 182, 63, 0.22);
  border-color: rgba(240, 182, 63, 0.46);
  color: #ffe6b2;
}

.badge-danger {
  background: rgba(245, 107, 107, 0.22);
  border-color: rgba(245, 107, 107, 0.52);
  color: #ffd3d3;
}

.core-status {
  border: 1px solid rgba(151, 170, 210, 0.3);
}

.core-content {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
  align-items: center;
}

.confidence-ring-wrap {
  text-align: center;
}

.confidence-ring {
  --ring-value: 0;
  width: 156px;
  height: 156px;
  margin: 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(closest-side, rgba(8, 15, 31, 0.95) 76%, transparent 77%),
    conic-gradient(from 190deg, #54e4c5 calc(var(--ring-value) * 1%), rgba(108, 129, 173, 0.22) 0);
  box-shadow: 0 0 36px rgba(84, 228, 197, 0.26);
  font-size: 30px;
  font-weight: 900;
}

.ring-caption {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.core-posture {
  margin: 0;
  font-size: clamp(34px, 4.2vw, 52px);
  font-weight: 900;
  line-height: 1.08;
}

.core-summary {
  margin: 8px 0 0;
  color: #cadeff;
}

.core-details {
  margin: 14px 0 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.core-details dt {
  font-size: 12px;
  color: var(--muted);
}

.core-details dd {
  margin: 4px 0 0;
  font-size: 16px;
  font-weight: 700;
}

.system-message {
  margin: 0 0 10px;
  color: #d2defd;
  min-height: 24px;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.health-label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.health-value {
  margin: 4px 0 0;
  font-size: 15px;
  font-weight: 700;
}

.progress-list {
  display: grid;
  gap: 10px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #d5e4ff;
  margin-bottom: 6px;
}

.progress-track {
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(132, 149, 190, 0.24);
}

.progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  transition: width 0.35s ease;
}

.score-good {
  background: linear-gradient(90deg, #44daac, #63f6da);
}

.score-mid {
  background: linear-gradient(90deg, #f4b25a, #f9d17b);
}

.score-low {
  background: linear-gradient(90deg, #f56b6b, #ff9c9c);
}

.visual-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.chart-panel canvas {
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid rgba(123, 145, 195, 0.18);
  background: rgba(5, 9, 20, 0.46);
}

.posture-timeline {
  border: 1px solid rgba(123, 145, 195, 0.24);
  border-radius: 10px;
  overflow: hidden;
  min-height: 34px;
  display: flex;
  background: rgba(6, 12, 28, 0.5);
}

.timeline-segment {
  flex: 1;
  min-width: 3px;
}

.timeline-empty {
  width: 100%;
  text-align: center;
  color: var(--muted);
  padding: 8px;
  font-size: 13px;
}

.timeline-legend {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.distribution-list {
  display: grid;
  gap: 10px;
}

.distribution-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px 12px;
  align-items: center;
}

.distribution-label,
.distribution-value {
  margin: 0;
  font-size: 13px;
}

.distribution-value {
  text-align: right;
  color: #d4def8;
}

.distribution-track {
  grid-column: 1 / -1;
  height: 8px;
  border-radius: 999px;
  background: rgba(136, 154, 191, 0.2);
  overflow: hidden;
}

.distribution-bar {
  height: 100%;
  border-radius: inherit;
}

.debug-preview pre,
.debug-shell pre {
  margin: 0;
  padding: 12px;
  border-radius: 10px;
  font-size: 12px;
  background: rgba(3, 8, 21, 0.86);
  color: #d6ecff;
  overflow: auto;
  max-height: 330px;
  border: 1px solid rgba(113, 137, 191, 0.25);
}

.debug-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid rgba(123, 145, 195, 0.2);
  white-space: nowrap;
}

.posture-lying_supine,
.posture-upright {
  color: var(--good);
}

.posture-side_left,
.posture-side_right {
  color: var(--amber);
}

.posture-prone {
  color: var(--danger);
}

.posture-moving {
  color: var(--blue);
}

.posture-unknown {
  color: var(--neutral);
}

.status-badge.posture-lying_supine,
.status-badge.posture-upright {
  background: rgba(56, 199, 147, 0.2);
  border-color: rgba(56, 199, 147, 0.45);
  color: #c4ffe9;
}

.status-badge.posture-side_left,
.status-badge.posture-side_right {
  background: rgba(240, 182, 63, 0.2);
  border-color: rgba(240, 182, 63, 0.45);
  color: #ffe7b5;
}

.status-badge.posture-prone {
  background: rgba(245, 107, 107, 0.22);
  border-color: rgba(245, 107, 107, 0.5);
  color: #ffd2d2;
}

.status-badge.posture-moving {
  background: rgba(105, 167, 255, 0.2);
  border-color: rgba(105, 167, 255, 0.45);
  color: #cde4ff;
}

.status-badge.posture-unknown {
  background: rgba(135, 145, 168, 0.22);
  border-color: rgba(135, 145, 168, 0.5);
  color: #d8dff0;
}

.core-status.posture-lying_supine,
.core-status.posture-upright {
  box-shadow: 0 0 0 1px rgba(56, 199, 147, 0.35), 0 14px 44px rgba(3, 6, 18, 0.6);
}

.core-status.posture-side_left,
.core-status.posture-side_right {
  box-shadow: 0 0 0 1px rgba(240, 182, 63, 0.35), 0 14px 44px rgba(3, 6, 18, 0.6);
}

.core-status.posture-prone {
  box-shadow: 0 0 0 1px rgba(245, 107, 107, 0.38), 0 14px 44px rgba(3, 6, 18, 0.6);
}

.core-status.posture-moving {
  box-shadow: 0 0 0 1px rgba(105, 167, 255, 0.35), 0 14px 44px rgba(3, 6, 18, 0.6);
}

.core-status.posture-unknown {
  box-shadow: 0 0 0 1px rgba(135, 145, 168, 0.35), 0 14px 44px rgba(3, 6, 18, 0.6);
}

.timeline-segment.posture-lying_supine,
.timeline-segment.posture-upright {
  background: var(--good);
}

.timeline-segment.posture-side_left,
.timeline-segment.posture-side_right {
  background: var(--amber);
}

.timeline-segment.posture-prone {
  background: var(--danger);
}

.timeline-segment.posture-moving {
  background: var(--blue);
}

.timeline-segment.posture-unknown {
  background: var(--neutral);
}

@media (max-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .core-content {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .core-details {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .hero-panel {
    flex-direction: column;
  }

  .hero-actions {
    width: 100%;
    min-width: 0;
  }

  .control-panel {
    flex-direction: column;
    align-items: flex-start;
  }

  .kpi-grid,
  .visual-grid {
    grid-template-columns: 1fr;
  }

  .distribution-row {
    grid-template-columns: 1fr;
  }

  .distribution-value {
    text-align: left;
  }

  .core-details {
    grid-template-columns: 1fr;
  }
}
