:root {
  color-scheme: light;
  --bg: #edf6f8;
  --panel: #ffffff;
  --ink: #102a38;
  --muted: #5d7280;
  --line: #c9dbe3;
  --accent: #087c9b;
  --accent-2: #d25454;
  --gold: #b8872f;
  --nav: #082f49;
  --nav-2: #0d4968;
  --soft: #e8f6f9;
  --blue-soft: #eaf5fb;
  --table-head: #0b334b;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #e8f6fa 0, #f5f8fa 340px, #eef4f6 100%);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 236px;
  padding: 22px 18px;
  background: linear-gradient(180deg, var(--nav), #061f35);
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
}

.brandMark {
  width: 44px;
  height: 44px;
  display: inline-block;
  background: linear-gradient(145deg, #f4bd5f, #2aa7c8 52%, #0e5f86 53%);
  clip-path: polygon(50% 0, 60% 32%, 96% 28%, 67% 50%, 82% 84%, 50% 64%, 18% 84%, 33% 50%, 4% 28%, 40% 32%);
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.28));
}

.brand strong {
  display: block;
  font-size: 22px;
  letter-spacing: 0;
}

.brand em {
  display: block;
  margin-top: 2px;
  color: #bdeaf3;
  font-size: 13px;
  font-style: normal;
}

.sideNav {
  display: grid;
  gap: 8px;
}

.sideNav a {
  color: #c7dce6;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 7px;
  font-size: 14px;
}

.sideNav a:hover,
.sideNav a.active {
  color: #fff;
  background: rgba(56, 189, 248, 0.18);
  box-shadow: inset 3px 0 0 #f4bd5f;
}

.sideNote {
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(125, 211, 252, 0.22);
  border-radius: 8px;
  color: #c7dce6;
  font-size: 12px;
  line-height: 1.55;
}

.sideNote b {
  display: block;
  margin-bottom: 4px;
  color: #fff;
}

.appMain {
  margin-left: 236px;
  padding: 22px 28px 34px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 16px;
  scroll-margin-top: 20px;
}

h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

#statusText,
.sectionHead p,
#radarStatus,
.newsMeta,
.newsDigest,
.sectorRisk p,
.hitLine,
.actionLine,
.muted,
.heatCard p,
.focusRow p {
  color: var(--muted);
  font-size: 13px;
}

.actions,
.watchActions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button,
.button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

button:hover,
.button:hover {
  filter: brightness(0.96);
}

button:disabled {
  opacity: 0.55;
  cursor: progress;
}

.button.secondary,
.secondaryAction,
.miniBtn {
  color: var(--accent);
  background: #fff;
}

.miniBtn {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.miniBtn.danger {
  border-color: #fecaca;
  color: #b91c1c;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metrics div,
.filters,
.radar,
.heatPanel,
.battlePanel,
.tableWrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(7, 47, 68, 0.06);
}

.metrics div {
  padding: 14px 16px;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  color: #08344c;
}

.filters {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) repeat(4, minmax(130px, 1fr));
  gap: 12px;
  padding: 14px;
  margin-bottom: 16px;
}

.radar,
.heatPanel,
.battlePanel {
  padding: 16px;
  margin-bottom: 16px;
  scroll-margin-top: 18px;
}

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

.sectionHead h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.radarSummary {
  margin-bottom: 12px;
}

.radarBrief {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fdff, #e8f6fb);
}

.briefMain strong {
  display: block;
  margin-top: 5px;
  font-size: 17px;
}

.brandTiny {
  color: #0b7894;
  font-size: 11px;
  font-weight: 700;
}

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

.riskCounts span {
  min-width: 56px;
  padding: 6px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.radarFocusGrid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.radarFocusGrid section,
.focusRow {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}

.radarFocusGrid section {
  padding: 12px;
}

.radarFocusGrid h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.focusRow {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  margin-bottom: 8px;
}

.focusRow p {
  margin: 4px 0 0;
}

#manualNewsText {
  width: 100%;
  min-height: 74px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  color: var(--ink);
  font-family: inherit;
  line-height: 1.5;
}

.radarResults,
.heatList,
.watchList {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.radarCard,
.heatCard,
.watchCard {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfe;
}

.radarTitle,
.sectorLine,
.heatTitle,
.watchTop,
.heatStats,
.watchStats {
  display: flex;
  gap: 10px;
  align-items: center;
}

.radarTitle,
.watchTop {
  justify-content: space-between;
  margin-bottom: 8px;
}

.radarTitle h3,
.heatTitle h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.4;
}

.riskBadge,
.statusTag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.statusTag {
  color: #075985;
  background: #e0f2fe;
  margin-right: 6px;
}

.riskHigh {
  color: #9b1c1c;
  background: #fee2e2;
}

.riskMid {
  color: #92400e;
  background: #fef3c7;
}

.riskLow {
  color: #166534;
  background: #dcfce7;
}

.sectorRisk {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.actionLine {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--blue-soft);
}

.leaderLine {
  margin-top: 8px;
  font-size: 13px;
}

.stockPill {
  min-height: 26px;
  margin: 0 6px 6px 0;
  padding: 0 8px;
  border-color: #bfd4df;
  background: #fff;
  color: #18394a;
}

.sourceLink {
  display: inline-flex;
  margin-top: 8px;
  color: var(--accent);
  font-size: 13px;
}

.heatCard {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
}

.heatRank {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: linear-gradient(160deg, #0b334b, #0c7894);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.heatTitle {
  justify-content: space-between;
  margin-bottom: 8px;
}

.heatStats,
.watchStats {
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.heatStats span,
.watchStats span {
  padding: 3px 7px;
  border-radius: 5px;
  background: #f1f5f9;
}

.watchForm {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  align-items: end;
}

.wideField {
  grid-column: span 2;
}

.watchPlan {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px;
}

.watchPlan p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.watchPlan b {
  display: block;
  color: var(--ink);
  margin-bottom: 3px;
}

label {
  color: var(--muted);
  font-size: 12px;
}

.inlineControl {
  min-width: 180px;
}

input,
select {
  width: 100%;
  height: 36px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(8, 124, 155, 0.18);
  border-color: #0b8eaa;
}

.tableWrap {
  overflow: auto;
  max-height: calc(100vh - 64px);
  scroll-margin-top: 18px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1360px;
  font-size: 13px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--table-head);
  color: #fff;
  text-align: left;
  padding: 10px;
  white-space: nowrap;
}

tbody td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  vertical-align: top;
}

tbody tr {
  background: #fff;
}

tbody tr:hover {
  background: var(--soft);
}

.code {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  font-family: Consolas, monospace;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
}

.thSort {
  min-height: 34px;
  min-width: 86px;
  padding: 0 10px;
  border: 1px solid rgba(186, 230, 253, 0.45);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.thSort::after {
  content: "↕";
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: #f4bd5f;
  color: #06283d;
  font-size: 17px;
  line-height: 1;
  opacity: 1;
}

.thSort:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(244, 189, 95, 0.95);
}

.num {
  text-align: right;
  white-space: nowrap;
}

.up {
  color: #c53030;
}

.down {
  color: #1f7a4d;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 5px;
  background: #eaf2f7;
  color: #244457;
  margin: 0 4px 4px 0;
  white-space: nowrap;
}

.leader {
  background: #fff5e6;
  color: var(--accent-2);
  font-weight: 700;
}

.unknown {
  color: var(--gold);
}

.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.45;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 32px;
}

.empty.compact {
  padding: 12px;
}

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.close {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 32px;
  padding: 0;
  justify-content: center;
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
  font-size: 20px;
}

.detailGrid {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 12px;
  line-height: 1.6;
}

.detailGrid b {
  color: var(--muted);
}

.detailWatchBtn {
  margin-top: 16px;
}

@media (max-width: 1080px) {
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100%;
    height: auto;
    padding: 10px 14px;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    overflow-x: auto;
    background: linear-gradient(90deg, var(--nav), var(--nav-2));
  }

  .brandMark {
    width: 34px;
    height: 34px;
  }

  .brand strong {
    font-size: 18px;
  }

  .sideNav {
    display: flex;
    gap: 6px;
  }

  .sideNav a {
    padding: 8px 10px;
  }

  .thSort {
    min-width: 94px;
  }

  .sideNote {
    display: none;
  }

  .appMain {
    margin-left: 0;
    padding: 18px 18px 30px;
  }

  .topbar,
  .sectionHead,
  .radarTitle,
  .watchTop {
    display: block;
  }

  .actions,
  .watchActions {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .metrics,
  .filters,
  .radarFocusGrid {
    grid-template-columns: 1fr 1fr;
  }

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

  .wideField {
    grid-column: span 2;
  }

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

@media (max-width: 640px) {
  .appMain {
    padding-left: 12px;
    padding-right: 12px;
  }

  .brand em,
  .sideNav a:nth-child(1) {
    display: none;
  }

  .metrics,
  .filters,
  .radarFocusGrid,
  .watchForm,
  .watchPlan {
    grid-template-columns: 1fr;
  }

  .wideField {
    grid-column: span 1;
  }

  .radarBrief,
  .focusRow {
    display: block;
  }

  .riskCounts {
    margin-top: 10px;
  }

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