:root {
  color-scheme: light;
  --bg: #f3f9ff;
  --panel: #ffffff;
  --ink: #142535;
  --muted: #5f7484;
  --line: #d8e8f4;
  --teal: #24a8ff;
  --blue: #1178d4;
  --amber: #b86b12;
  --red: #bd3a3a;
  --green: #24835a;
  --soft-teal: #e8f6ff;
  --soft-blue: #edf7ff;
  --soft-amber: #fff2df;
  --shadow: 0 12px 30px rgba(32, 121, 190, 0.08);
  font-family: "Microsoft YaHei", "微软雅黑", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "微软雅黑", "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1680px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.sync-box {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
}

button:hover {
  border-color: var(--teal);
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-shell {
  width: min(420px, 100%);
}

.auth-card {
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin-bottom: 22px;
  font-size: 30px;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form button {
  min-height: 42px;
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
  font-weight: 700;
}

.auth-message {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(8, minmax(130px, 1fr));
  gap: 12px;
  padding: 14px;
  margin-bottom: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.view-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.view-tab {
  min-height: 44px;
  border-color: var(--line);
  background: #f8fcff;
  color: var(--muted);
  font-weight: 800;
}

.view-tab.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
input {
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fbfcfd;
  color: var(--ink);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  min-height: 114px;
  padding: 15px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kpi span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.kpi strong {
  display: block;
  margin-top: 12px;
  font-size: 25px;
  line-height: 1;
  white-space: nowrap;
}

.delta {
  display: inline-flex;
  align-items: center;
  margin-top: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.delta.up {
  background: #faeaea;
  color: var(--red);
}

.delta.down {
  background: #e8f6ee;
  color: var(--green);
}

.delta.flat {
  background: #eef2f3;
  color: var(--muted);
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.9fr);
  align-items: start;
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  min-width: 0;
  margin-bottom: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.section-grid .panel {
  margin-bottom: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--line);
}

.panel-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.download-btn {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 6px 10px;
  color: var(--blue);
  background: #f7fcff;
  font-size: 12px;
  font-weight: 700;
}

.chart {
  min-height: 300px;
  padding: 18px;
}

.chart svg {
  width: 100%;
  height: 280px;
  display: block;
}

.axis-label {
  fill: #6b7780;
  font-size: 11px;
}

.rank-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 16px 18px 18px;
}

.compact-list,
.insight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 18px 18px;
}

.rank-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.rank-item:last-child {
  border-bottom: 0;
}

.rank-item strong,
.compact-card strong {
  font-size: 14px;
}

.bar {
  grid-column: 1 / -1;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f3;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
}

.table-wrap {
  overflow: auto;
  padding: 0 18px 18px;
}

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

.dms-table {
  min-width: 680px;
}

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

th:first-child,
td:first-child,
td.name,
th.name {
  text-align: left;
}

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

.name {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.share-cell {
  min-width: 150px;
}

.mini-track {
  height: 8px;
  margin-top: 4px;
  border-radius: 999px;
  background: #edf1f3;
}

.mini-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--amber);
}

.compact-card,
.insight {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.category-blocks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 16px 18px 18px;
}

.category-block {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  background: #fbfcfd;
}

.category-block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fbfb;
}

.category-block-head div {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.category-block-head strong {
  font-size: 16px;
}

.mini-table {
  min-width: 960px;
}

.compact-card p,
.insight p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.compact-list .compact-card {
  margin-bottom: 10px;
}

.compact-list .compact-card:last-child {
  margin-bottom: 0;
}

.pill {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--soft-teal);
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
}

.risk {
  background: #faeaea;
  color: var(--red);
}

.chance {
  background: var(--soft-blue);
  color: var(--blue);
}

.empty {
  padding: 24px;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 1180px) {
  .filters {
    grid-template-columns: repeat(4, 1fr);
  }

  .view-tabs {
    grid-template-columns: 1fr;
  }

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

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

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

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 20px, 680px);
    padding-top: 14px;
  }

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

  .sync-box {
    width: 100%;
    justify-content: space-between;
  }

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

  .category-blocks {
    grid-template-columns: 1fr;
  }

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

  table {
    min-width: 820px;
  }
}
