:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f9fbfc;
  --text: #17212b;
  --muted: #64717f;
  --line: #dce3ea;
  --blue: #1f6feb;
  --green: #138a54;
  --red: #c43d3d;
  --amber: #ad6b00;
  --shadow: 0 10px 28px rgba(25, 34, 44, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
  padding-bottom: 42px;
}

.side-nav {
  position: sticky;
  top: 0;
  display: grid;
  align-content: start;
  gap: 18px;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

.brand-block {
  display: grid;
  gap: 4px;
  padding: 8px 8px 14px;
  border-bottom: 1px solid var(--line);
}

.brand-block strong {
  font-size: 17px;
}

.brand-block span,
.side-status small,
.topbar p,
.section-head p,
.panel-head span,
.list-row small,
.alert-item small,
.data-table small,
.report-card span,
.report-card p,
.timeline-item p {
  color: var(--muted);
  line-height: 1.45;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  text-align: left;
  font-weight: 700;
}

.nav-item:hover,
.nav-item.active {
  border-color: #c7d7ed;
  background: #edf4ff;
  color: #0e4a9d;
}

.side-status {
  display: grid;
  gap: 5px;
  margin-top: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.main-workspace {
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
  padding: 18px;
}

.topbar,
.section-head,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

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

h1 {
  font-size: 22px;
  line-height: 1.25;
}

h2 {
  font-size: 16px;
}

h3 {
  font-size: 15px;
}

.top-actions,
.row-actions,
.fund-tabs,
.inline-form,
.channel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.primary-btn,
.ghost-btn,
.small-btn,
.segment,
.icon-btn {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

.primary-btn {
  padding: 0 13px;
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.ghost-btn,
.segment,
.small-btn {
  padding: 0 11px;
}

.small-btn {
  min-height: 28px;
  font-size: 12px;
}

.small-btn.danger {
  color: var(--red);
  border-color: #f0c8c8;
}

.segment.active {
  border-color: var(--blue);
  background: #edf4ff;
  color: #0e4a9d;
}

.icon-btn {
  width: 34px;
  padding: 0;
  font-size: 20px;
}

.load-banner {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid #c7d7ed;
  border-radius: 8px;
  background: #edf4ff;
}

.load-banner.hidden {
  display: none;
}

.view {
  display: none;
  gap: 14px;
}

.view.active {
  display: grid;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(0, 2.2fr);
  gap: 14px;
}

.emotion-panel,
.panel,
.metric-card,
.index-card,
.report-card,
.timeline-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.emotion-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.emotion-panel > span,
.metric-card span,
.index-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.emotion-panel strong {
  font-size: 26px;
}

.score-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

meter {
  width: 100%;
  height: 12px;
}

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

.index-card,
.metric-card {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.index-card strong,
.metric-card strong {
  font-size: 18px;
}

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

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.compact-list,
.alert-list,
.channel-list,
.tag-list,
.timeline,
.report-grid {
  display: grid;
  gap: 8px;
}

.list-row,
.alert-item,
.channel-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.list-row small,
.alert-item small {
  grid-column: 1 / -1;
}

.alert-item.high {
  border-color: #f1b6b6;
  background: #fff5f5;
}

.alert-item.medium,
.timeline-item.medium {
  border-color: #eed49b;
  background: #fffaf0;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.data-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f9fb;
  color: var(--muted);
  font-size: 12px;
}

.data-table td strong,
.data-table td span,
.data-table td small {
  display: block;
}

.stock-table {
  min-width: 1180px;
}

.inline-form input {
  width: 150px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.push-form {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(120px, 1fr) minmax(180px, 1.4fr) minmax(160px, 1.1fr) auto;
  gap: 8px;
}

.push-form input,
.push-form select {
  min-width: 0;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.report-grid {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.report-card {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.mini-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-list small,
.tag {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
}

.timeline-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  box-shadow: none;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-message-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.source-message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.source-message-head span {
  color: var(--muted);
  font-size: 12px;
}

.source-message {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.source-message small,
.source-message p {
  color: var(--muted);
  line-height: 1.45;
}

.source-message a,
.source-message strong {
  color: var(--text);
  font-weight: 800;
  line-height: 1.35;
  text-decoration: none;
}

.source-message a:hover {
  color: var(--blue);
  text-decoration: underline;
}

.source-message p {
  margin: 0;
}

.source-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.source-tags span {
  padding: 2px 6px;
  border-radius: 999px;
  background: #edf4ff;
  color: #0e4a9d;
  font-size: 12px;
  font-weight: 800;
}

.channel-row {
  align-items: center;
}

.channel-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.channel-actions {
  grid-column: 1 / -1;
}

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

.up {
  color: var(--green);
}

.down,
.danger-row strong,
.risk-text {
  color: var(--red);
}

.flow-in {
  color: var(--red);
}

.flow-out {
  color: var(--green);
}

.flat {
  color: var(--muted);
}

.edit-dialog {
  width: min(620px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}

.edit-dialog::backdrop {
  background: rgba(23, 33, 43, 0.32);
}

.edit-dialog form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.edit-dialog header,
.edit-dialog footer,
.edit-dialog .wide {
  grid-column: 1 / -1;
}

.edit-dialog header,
.edit-dialog footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.edit-dialog label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.edit-dialog input {
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.risk-footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 236px;
  z-index: 5;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-nav {
    position: static;
    height: auto;
  }

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

  .dashboard-grid,
  .two-column,
  .settings-grid {
    grid-template-columns: 1fr;
  }

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

  .risk-footer {
    left: 0;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 13px;
  }

  .main-workspace,
  .side-nav {
    padding: 12px;
  }

  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-list,
  .index-grid,
  .metrics-grid,
  .report-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .fund-tabs,
  .inline-form,
  .push-form,
  .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inline-form input,
  .inline-form button,
  .push-form input,
  .push-form select,
  .push-form button,
  .top-actions button,
  .fund-tabs button {
    width: 100%;
  }

  .edit-dialog form {
    grid-template-columns: 1fr;
  }

  .risk-footer {
    position: static;
    margin-top: 12px;
  }
}
