:root {
  color-scheme: dark;
  --bg: #090b0f;
  --panel: rgba(20, 25, 31, 0.86);
  --panel-strong: rgba(31, 38, 45, 0.95);
  --line: rgba(184, 207, 218, 0.16);
  --text: #f3f7f7;
  --muted: #8d9da0;
  --cyan: #28d7d7;
  --mint: #55d68b;
  --amber: #f0bb50;
  --coral: #ff6b5f;
  --violet: #a78bfa;
  --ink: #0f1419;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(145deg, rgba(40, 215, 215, 0.07), transparent 38%),
    linear-gradient(315deg, rgba(240, 187, 80, 0.05), transparent 42%),
    var(--bg);
  background-size: 56px 56px, 56px 56px, auto, auto, auto;
  color: var(--text);
  letter-spacing: 0;
  overflow-x: hidden;
}

#matrix-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.26;
  pointer-events: none;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.topbar,
.control-row,
.kpi-grid,
.main-grid,
.wide-grid {
  display: grid;
  gap: 14px;
}

.topbar {
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-bottom: 18px;
}

.identity {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(40, 215, 215, 0.55);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(40, 215, 215, 0.2), rgba(240, 187, 80, 0.12));
  color: var(--cyan);
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 750;
  letter-spacing: 0;
}

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

h2 {
  font-size: 18px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(128px, auto));
  border: 1px solid var(--line);
  background: rgba(12, 16, 20, 0.72);
  border-radius: 8px;
  overflow: hidden;
}

.status-strip div {
  padding: 12px 16px;
  border-left: 1px solid var(--line);
}

.status-strip div:first-child {
  border-left: 0;
}

.status-strip span,
.kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.status-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  white-space: nowrap;
}

.control-row {
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-bottom: 14px;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  justify-content: start;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 16, 20, 0.72);
}

button {
  min-width: 84px;
  height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

button.active {
  background: rgba(40, 215, 215, 0.16);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(40, 215, 215, 0.35);
}

.legend {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
}

.cyan { background: var(--cyan); }
.amber { background: var(--amber); }
.coral { background: var(--coral); }

.kpi-grid {
  grid-template-columns: 1.45fr repeat(3, 1fr);
  margin-bottom: 14px;
}

.kpi,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(16px);
}

.kpi {
  min-height: 132px;
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.kpi::after,
.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255,255,255,0.11), transparent 32%, rgba(40,215,215,0.05));
  opacity: 0.55;
}

.kpi.primary {
  display: grid;
  grid-template-columns: 1fr 112px;
  align-items: center;
}

.kpi strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
}

.kpi small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.ring {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--cyan) 0deg, rgba(255,255,255,0.09) 0deg);
}

.ring span {
  display: block;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: #10151a;
  box-shadow: inset 0 0 24px rgba(40, 215, 215, 0.12);
}

.main-grid {
  grid-template-columns: 0.9fr 1.1fr;
  margin-bottom: 14px;
}

.wide-grid {
  grid-template-columns: 1.1fr 0.9fr;
  margin-bottom: 14px;
}

.panel {
  position: relative;
  padding: 18px;
  overflow: hidden;
}

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

.chip {
  border: 1px solid rgba(40, 215, 215, 0.28);
  border-radius: 999px;
  padding: 6px 10px;
  color: #bfe9e8;
  background: rgba(40, 215, 215, 0.08);
  font-size: 12px;
  white-space: nowrap;
}

.area-compare {
  display: grid;
  gap: 14px;
}

.area-row {
  display: grid;
  grid-template-columns: 92px 1fr 80px;
  gap: 12px;
  align-items: center;
}

.bar-stack {
  display: grid;
  gap: 6px;
}

.bar-track {
  height: 12px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  transform-origin: left center;
}

.bar-fill.overall { background: linear-gradient(90deg, var(--cyan), var(--mint)); }
.bar-fill.time { background: linear-gradient(90deg, var(--amber), #ffe08c); }

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

.metric-tile {
  min-height: 176px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 15, 19, 0.64);
}

.metric-tile h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

.metric-value {
  font-size: 28px;
  font-weight: 760;
}

.metric-meta {
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.mini-track {
  height: 7px;
  margin-top: 13px;
  border-radius: 99px;
  background: rgba(255,255,255,0.09);
  overflow: hidden;
}

.mini-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--violet), var(--cyan));
}

.contribution {
  display: grid;
  gap: 12px;
}

.contribution-row {
  display: grid;
  grid-template-columns: 118px 1fr 72px;
  gap: 12px;
  align-items: center;
}

.risk-brief {
  display: grid;
  gap: 12px;
}

.brief-item {
  border-left: 3px solid var(--coral);
  padding: 10px 12px;
  background: rgba(255, 107, 95, 0.08);
  border-radius: 0 8px 8px 0;
}

.brief-item strong {
  display: block;
  margin-bottom: 4px;
}

.brief-item span {
  color: var(--muted);
  font-size: 13px;
}

.table-panel {
  margin-bottom: 10px;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 650;
}

.risk-pill {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255, 107, 95, 0.12);
  color: #ffb1aa;
  border: 1px solid rgba(255, 107, 95, 0.25);
}

.positive { color: var(--mint); }
.negative { color: var(--coral); }
.muted { color: var(--muted); }

@media (max-width: 1080px) {
  .topbar,
  .control-row,
  .kpi-grid,
  .main-grid,
  .wide-grid {
    grid-template-columns: 1fr;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .status-strip div {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .status-strip div:first-child {
    border-top: 0;
  }

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

@media (max-width: 640px) {
  .shell {
    width: min(100% - 24px, 1480px);
    padding-top: 18px;
  }

  .identity {
    align-items: flex-start;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
  }

  .segmented {
    grid-auto-flow: row;
    width: 100%;
  }

  button {
    width: 100%;
  }

  .legend {
    flex-wrap: wrap;
  }

  .kpi.primary {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .metric-matrix {
    grid-template-columns: 1fr;
  }

  .area-row,
  .contribution-row {
    grid-template-columns: 1fr;
  }
}
