﻿:root {
  --bg: #07142f;
  --bg-soft: #0b1f42;
  --panel: #152a4f;
  --panel-alt: #1a325b;
  --text: #eaf1ff;
  --text-soft: #a6b8de;
  --line: rgba(153, 180, 230, 0.22);
  --safe: #00d09c;
  --warning: #f7b514;
  --danger: #ff4d6d;
  --accent: #5da9ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% -10%, #14356f 0, transparent 40%),
    radial-gradient(circle at 95% 0, #1a2660 0, transparent 34%),
    linear-gradient(160deg, #061128 0%, #071431 42%, #08152f 100%);
}

.bg-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
}

.orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(40px);
  opacity: 0.25;
}

.orb-a {
  width: 320px;
  height: 320px;
  background: #1f63ff;
  top: -120px;
  left: -80px;
}

.orb-b {
  width: 280px;
  height: 280px;
  background: #00d09c;
  right: -120px;
  top: 190px;
}

.orb-c {
  width: 240px;
  height: 240px;
  background: #ff9500;
  left: 26%;
  bottom: -100px;
}

.dashboard {
  width: min(1320px, 92vw);
  margin: 26px auto 36px;
  display: grid;
  gap: 16px;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding: 8px 2px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: #79a5ff;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 800;
  line-height: 1.2;
}

.subtext {
  margin: 8px 0 0;
  color: var(--text-soft);
  font-size: 13px;
}

.header-meta {
  min-width: 220px;
  text-align: right;
}

.meta-line {
  margin: 0;
  font-size: 12px;
  color: #8fb5ff;
}

.meta-time {
  margin: 7px 0 10px;
  font-size: 12px;
  color: var(--text-soft);
}

.refresh-btn,
.ghost-btn {
  border: 1px solid #2f4f8b;
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 600;
}

.refresh-btn {
  background: linear-gradient(135deg, #203d72, #1a335c);
}

.ghost-btn {
  background: rgba(18, 33, 60, 0.7);
}

.refresh-btn:hover,
.ghost-btn:hover {
  border-color: #4b73bf;
}

.panel {
  background: linear-gradient(180deg, rgba(25, 49, 88, 0.95), rgba(17, 35, 66, 0.97));
  border: 1px solid rgba(138, 172, 229, 0.2);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 10px 30px rgba(5, 13, 32, 0.34);
  animation: fadeUp 0.45s ease;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
}

.source-controls {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 8px;
  align-items: end;
}

.source-input-wrap {
  display: grid;
  gap: 6px;
}

.source-input-wrap span {
  font-size: 12px;
  color: #b8ccf2;
}

.source-input-wrap input {
  border-radius: 8px;
  border: 1px solid rgba(141, 170, 219, 0.42);
  background: rgba(14, 28, 54, 0.9);
  color: #f2f7ff;
  padding: 9px 11px;
  font-size: 13px;
}

.source-tip,
.source-status,
.macro-tip {
  margin: 10px 0 0;
  font-size: 12px;
  color: #bad0f8;
}

.source-status {
  color: #d9e7ff;
}

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

.alert-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 10px;
}

.alert-card {
  border-radius: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(28, 48, 86, 0.9);
}

.alert-card h3 {
  margin: 0;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-card p {
  margin: 8px 0 0;
  color: #d6e3ff;
  font-size: 12px;
  line-height: 1.5;
}

.alert-card.warning {
  background: linear-gradient(155deg, rgba(112, 72, 14, 0.9), rgba(89, 55, 13, 0.86));
  border-color: rgba(255, 185, 31, 0.5);
}

.alert-card.danger {
  background: linear-gradient(150deg, rgba(117, 24, 49, 0.92), rgba(80, 20, 41, 0.86));
  border-color: rgba(255, 91, 127, 0.52);
}

.alert-card.info {
  background: linear-gradient(150deg, rgba(24, 58, 110, 0.94), rgba(24, 51, 93, 0.9));
  border-color: rgba(95, 162, 255, 0.46);
}

.alert-counts {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.alert-counts div {
  border-radius: 7px;
  background: rgba(9, 16, 33, 0.42);
  padding: 6px 8px;
  font-size: 12px;
}

.alert-counts span {
  display: block;
  font-size: 15px;
  margin-top: 3px;
  font-weight: 700;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 10px;
}

.kpi-card {
  background: linear-gradient(165deg, #203964, #1a2f56);
  border-radius: 10px;
  border: 1px solid rgba(145, 174, 226, 0.22);
  padding: 11px 12px;
}

.kpi-card p {
  margin: 0;
  color: var(--text-soft);
  font-size: 12px;
}

.kpi-card strong {
  display: block;
  margin-top: 7px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  border: 1px solid rgba(150, 176, 222, 0.32);
  background: rgba(21, 40, 72, 0.8);
  color: #cddcff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.chip.active {
  border-color: rgba(87, 217, 174, 0.66);
  background: rgba(15, 75, 62, 0.55);
  color: #b7ffe9;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(230px, 1fr));
  gap: 10px;
}

.metric-card {
  border-radius: 10px;
  border: 1px solid rgba(124, 154, 207, 0.2);
  background: linear-gradient(170deg, #1d345d, #182c52);
  padding: 12px;
  min-height: 190px;
  display: grid;
  grid-template-rows: auto auto auto auto 1fr auto;
  gap: 6px;
}

.metric-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-soft);
}

.metric-name {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
}

.metric-value {
  margin: 0;
  font-size: 29px;
  font-weight: 800;
  font-family: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}

.metric-source,
.metric-threshold,
.metric-purpose {
  margin: 0;
  color: #c7d8ff;
  font-size: 12px;
  line-height: 1.5;
}

.metric-source {
  color: #90b8ff;
}

.metric-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}

.status-safe .status-dot,
.badge-safe {
  background: var(--safe);
}

.status-warning .status-dot,
.badge-warning {
  background: var(--warning);
}

.status-danger .status-dot,
.badge-danger {
  background: var(--danger);
}

.badge {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  color: #081022;
}

.distance {
  font-size: 12px;
  color: #c4d6fd;
}

.metric-card.status-warning {
  border-color: rgba(255, 194, 64, 0.55);
  box-shadow: inset 0 0 0 1px rgba(255, 180, 20, 0.18);
}

.metric-card.status-danger {
  border-color: rgba(255, 101, 131, 0.6);
  box-shadow: inset 0 0 0 1px rgba(255, 95, 128, 0.2);
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px;
}

.chart-card {
  border: 1px solid rgba(129, 161, 211, 0.24);
  border-radius: 10px;
  background: linear-gradient(180deg, #1b3158, #162b4f);
  padding: 10px;
}

.chart-title {
  margin: 0 0 8px;
  color: #cfe0ff;
  font-size: 12px;
}

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

#chart-risk {
  height: 280px;
}

.risk-legend {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 8px;
}

.legend-item {
  border-radius: 8px;
  padding: 9px 10px;
  background: rgba(11, 22, 44, 0.46);
  border: 1px solid rgba(114, 145, 195, 0.2);
  font-size: 12px;
}

.legend-item b {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

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

.proximity-row {
  border: 1px solid rgba(129, 160, 215, 0.22);
  border-radius: 10px;
  padding: 9px 11px;
  background: rgba(18, 35, 66, 0.78);
}

.proximity-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 6px;
}

.proximity-head span {
  color: #d8e4ff;
  font-family: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}

.proximity-track {
  height: 9px;
  border-radius: 999px;
  background: rgba(10, 18, 35, 0.8);
  overflow: hidden;
}

.proximity-fill {
  height: 100%;
  border-radius: inherit;
  display: block;
}

.proximity-fill.safe {
  background: linear-gradient(90deg, #11c78f, #39f4be);
}

.proximity-fill.warning {
  background: linear-gradient(90deg, #f2a803, #ffd46d);
}

.proximity-fill.danger {
  background: linear-gradient(90deg, #e64464, #ff8da1);
}

.proximity-hint {
  margin: 6px 0 0;
  color: #9ab3df;
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(130, 161, 212, 0.24);
  border-radius: 10px;
}

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

thead {
  background: rgba(14, 28, 54, 0.95);
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 10px 11px;
  border-bottom: 1px solid rgba(132, 162, 210, 0.2);
  font-size: 12px;
}

th {
  font-size: 12px;
  color: #c8dbff;
  white-space: nowrap;
}

td {
  color: #d9e6ff;
  line-height: 1.45;
}

.status-text {
  color: #081022;
  font-size: 11px;
  font-weight: 700;
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
}

.mm-input {
  width: 170px;
  border-radius: 6px;
  border: 1px solid rgba(141, 170, 219, 0.42);
  background: rgba(14, 28, 54, 0.9);
  color: #f2f7ff;
  padding: 6px 8px;
  font-size: 12px;
}

.mm-diff.good {
  color: var(--safe);
}

.mm-diff.warn {
  color: var(--warning);
}

.mm-diff.bad {
  color: var(--danger);
}

.external-link {
  color: #8fc5ff;
  text-decoration: none;
}

.external-link:hover {
  text-decoration: underline;
}

.note-panel .notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 10px;
}

.notes article {
  border-radius: 10px;
  padding: 12px;
  background: rgba(15, 30, 58, 0.8);
  border: 1px solid rgba(123, 156, 209, 0.22);
}

.notes h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.notes ul {
  margin: 0;
  padding-left: 18px;
  color: #cadcff;
  font-size: 12px;
  line-height: 1.6;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1120px) {
  .source-controls {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .chart-grid,
  .alert-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .dashboard {
    width: min(96vw, 1320px);
    margin-top: 16px;
  }

  .dashboard-header {
    flex-direction: column;
  }

  .header-meta {
    text-align: left;
    min-width: 0;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

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

  .metric-grid,
  .note-panel .notes,
  .risk-legend {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }
}

/* Mobile: keep desktop layout ratio, scale the whole dashboard to fit viewport width. */
@media (max-width: 760px) {
  body {
    overflow-x: hidden;
  }

  .dashboard {
    width: 1320px;
    margin: 14px 0 24px;
    transform-origin: top left;
    transform: scale(calc((100vw - 12px) / 1320));
  }

  .dashboard-header {
    flex-direction: row;
    align-items: flex-start;
  }

  .header-meta {
    text-align: right;
    min-width: 220px;
  }

  .kpi-grid {
    grid-template-columns: repeat(5, minmax(160px, 1fr));
  }

  .panel-head {
    flex-direction: row;
    align-items: center;
  }

  .metric-grid {
    grid-template-columns: repeat(3, minmax(230px, 1fr));
  }

  .note-panel .notes,
  .risk-legend {
    grid-template-columns: repeat(2, minmax(240px, 1fr));
  }

  h1 {
    font-size: clamp(24px, 3vw, 34px);
  }
}
