:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --ink: #20242b;
  --muted: #69717b;
  --line: #d9d1c2;
  --panel: #fffdf8;
  --panel-2: #f8fbfd;
  --good: #1f8a67;
  --warn: #c05138;
  --mid: #6b7280;
  --blue: #2f6fba;
  --gold: #b5832f;
  --shadow: 0 16px 44px rgba(46, 36, 24, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.82), rgba(255,255,255,0.22) 38%, transparent),
    var(--bg);
  color: var(--ink);
  font-family: SimHei, "Microsoft YaHei", "Noto Sans SC", "PingFang SC", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 0 18px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 52px);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
}

h3 {
  margin-bottom: 0;
  font-size: 17px;
}

.range-panel {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(58px, 1fr));
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.7);
}

.range-btn,
.icon-text,
.refresh {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
}

.range-btn.active {
  background: var(--ink);
  color: #fff;
}

.custom-range {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
}

.custom-range input {
  width: 190px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
}

.icon-text {
  padding: 0 14px;
  background: var(--blue);
  color: #fff;
}

.text-link {
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  justify-self: end;
}

.login-view {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(244, 241, 234, 0.96);
}

.login-view[hidden] {
  display: none;
}

.login-panel {
  width: min(460px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  font-size: 30px;
}

.login-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.login-panel input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

.login-error {
  min-height: 18px;
  margin: 0;
  color: var(--warn);
  font-weight: 800;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 44px;
  gap: 10px;
  align-items: stretch;
  margin: 8px 0 18px;
}

.status-strip > div,
.refresh {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.76);
}

.status-strip > div {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
}

.status-strip span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status-strip strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.refresh {
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-size: 20px;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.project-card {
  min-height: 176px;
  display: grid;
  align-content: space-between;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(49, 43, 34, 0.06);
  text-align: left;
}

.project-card.active {
  outline: 3px solid color-mix(in srgb, var(--accent), white 55%);
}

.project-card h3 {
  min-height: 42px;
  line-height: 1.25;
}

.metrics {
  display: grid;
  gap: 7px;
}

.metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  color: var(--ink);
  font-size: 15px;
}

.badge {
  width: max-content;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border-radius: 999px;
  background: #edf7f1;
  color: var(--good);
  font-size: 12px;
  font-weight: 900;
}

.badge.warn {
  background: #fff0ec;
  color: var(--warn);
}

.detail-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.detail-side,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.detail-side {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 18px;
  padding: 18px;
}

.project-heading {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 12px;
  align-items: start;
}

.accent-dot {
  width: 14px;
  height: 46px;
  border-radius: 7px;
  background: var(--blue);
}

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

.section-head > span {
  min-width: 34px;
  min-height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #eef2f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.risk-list,
.message-list {
  display: grid;
  gap: 10px;
}

.risk-item,
.message-item {
  border: 1px solid #e4ded2;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.risk-item strong,
.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.risk-tags,
.msg-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  min-height: 22px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #f1e7dd;
  color: #7c4b22;
  font-size: 12px;
  font-weight: 800;
}

.detail-main {
  display: grid;
  gap: 18px;
}

.panel {
  padding: 18px;
}

.panel {
  position: relative;
}

.legend {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.legend span::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 5px;
  border-radius: 50%;
}

.legend .pos::before { background: var(--good); }
.legend .neu::before { background: var(--mid); }
.legend .neg::before { background: var(--warn); }

.trend-chart {
  width: 100%;
  height: auto;
  min-height: 240px;
  display: block;
}

.trend-bar {
  cursor: crosshair;
  transition: opacity 0.15s ease, filter 0.15s ease;
}

.trend-bar:hover {
  opacity: 0.78;
  filter: drop-shadow(0 2px 4px rgba(32, 36, 43, 0.2));
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  display: grid;
  gap: 4px;
  min-width: 150px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 10px 28px rgba(32, 36, 43, 0.14);
  color: var(--ink);
  font-size: 12px;
  pointer-events: none;
}

.chart-tooltip[hidden] {
  display: none;
}

.word-cloud {
  position: relative;
  min-height: 330px;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  align-items: center;
  justify-content: center;
  gap: 12px 16px;
  overflow: hidden;
  padding: 42px 58px;
  border: 1px solid #e3dacd;
  border-radius: 48% 52% 46% 54% / 58% 44% 56% 42%;
  background:
    radial-gradient(circle at 26% 42%, rgba(255,255,255,0.96) 0 31%, transparent 32%),
    radial-gradient(circle at 47% 27%, rgba(255,255,255,0.98) 0 28%, transparent 29%),
    radial-gradient(circle at 68% 43%, rgba(255,255,255,0.96) 0 31%, transparent 32%),
    linear-gradient(180deg, #f8fdff, #fff8ef);
}

.cloud-word {
  position: static;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  max-width: 100%;
  border: 0;
  background: transparent;
  color: var(--word-color);
  font-weight: 900;
  white-space: nowrap;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255,255,255,0.9);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.cloud-word:hover,
.cloud-word:focus-visible {
  transform: translateY(-2px) scale(1.06);
  filter: drop-shadow(0 4px 8px rgba(32, 36, 43, 0.18));
  outline: none;
}

.cloud-word small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.messages-panel {
  max-height: 720px;
  overflow: auto;
}

.message-item {
  display: grid;
  gap: 8px;
}

.message-content {
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.empty,
.loading {
  min-height: 110px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.56);
}

@media (max-width: 1260px) {
  .project-grid {
    grid-template-columns: repeat(4, minmax(170px, 1fr));
  }
}

@media (max-width: 900px) {
  .topbar,
  .detail-layout {
    grid-template-columns: 1fr;
    display: grid;
  }

  .range-panel {
    justify-items: stretch;
  }

  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-side {
    position: static;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 20px, 1480px);
    padding-top: 12px;
  }

  .status-strip,
  .custom-range,
  .project-grid {
    grid-template-columns: 1fr;
  }

  .custom-range input {
    width: 100%;
  }

  .project-card {
    min-height: 150px;
  }

  .word-cloud {
    min-height: 270px;
  }
}
