:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --ink: #20242a;
  --muted: #667085;
  --line: #d6dbe3;
  --soft-line: #e8ebf0;
  --blue: #4285f4;
  --blue-strong: #1a73e8;
  --blue-soft: #d8e9ff;
  --orange: #f2994a;
  --purple: #9b72df;
  --green: #9bbb59;
  --cyan: #2bb8c7;
  --yellow: #e9c33a;
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: 74px 1fr;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 26px;
  background: #f8fbff;
  border-bottom: 1px solid var(--soft-line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
}

.brand strong,
.brand span {
  display: block;
}

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

.brand span {
  color: var(--muted);
  font-size: 14px;
  margin-top: 2px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border: 2px solid var(--blue);
  border-radius: 50%;
  position: relative;
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  border: 2px solid var(--blue);
  border-radius: 50%;
  background: #fff;
}

.brand-mark::before {
  left: -7px;
  bottom: -2px;
}

.brand-mark::after {
  right: -6px;
  top: -6px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  min-width: 0;
}

.date-select {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  position: relative;
}

.site-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.site-tab {
  min-width: 94px;
  height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #344054;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

.site-tab.active {
  color: #fff;
  background: var(--blue-strong);
  box-shadow: 0 1px 3px rgba(26, 115, 232, 0.24);
}

select,
input {
  height: 38px;
  min-width: 150px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
}

.date-select input,
.date-button {
  min-width: 278px;
}

.date-button {
  height: 48px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.date-button::after {
  content: "▾";
  margin-left: auto;
  color: #596273;
  font-size: 12px;
}

.date-button span:first-child {
  min-width: 76px;
  color: #2f343d;
  font-weight: 700;
}

.date-button span:nth-child(2) {
  color: #596273;
}

.date-popover {
  position: absolute;
  top: 48px;
  right: 0;
  z-index: 20;
  width: 560px;
  padding: 8px 12px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 8px 26px rgba(16, 24, 40, 0.18);
  color: #2f343d;
}

.date-popover-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
  height: 40px;
  border-bottom: 1px solid transparent;
}

.date-popover-header label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #2f343d;
  font-size: 16px;
}

.date-popover-header input {
  min-width: 0;
  width: 22px;
  height: 22px;
}

.preset-select {
  width: 188px;
  min-width: 188px;
  height: 40px;
  color: #6b7280;
  background: #f7f8fa;
}

.calendar-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 26px;
  padding: 8px 18px 2px;
}

.calendar-pane-title {
  text-align: center;
  font-weight: 700;
  font-size: 16px;
  margin: 0 0 14px;
}

.calendar-month {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 18px;
  font-weight: 700;
}

.calendar-month-selects {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.calendar-month-selects select {
  min-width: 72px;
  height: 30px;
  padding: 0 18px 0 4px;
  border: 0;
  background: transparent;
  color: #2f343d;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
}

.calendar-month-selects select:nth-child(2) {
  min-width: 54px;
}

.calendar-month button {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: #20242a;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.calendar-week,
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
}

.calendar-week {
  padding-bottom: 8px;
  border-bottom: 1px solid #e0e3e7;
  color: #747b85;
  font-size: 14px;
}

.calendar-days {
  gap: 2px 0;
  padding-top: 8px;
}

.calendar-day {
  width: 32px;
  height: 32px;
  margin: 0 auto;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: #2f343d;
  font-size: 16px;
  cursor: pointer;
}

.calendar-day.outside {
  color: transparent;
  pointer-events: none;
}

.calendar-day.in-range {
  background: #f3f8ff;
}

.calendar-day.selected {
  color: #fff;
  background: #0b63ce;
  font-weight: 700;
}

.calendar-day.today {
  border-color: #7b8088;
}

.date-actions {
  display: flex;
  justify-content: flex-end;
  gap: 30px;
  padding: 12px 10px 0;
}

.date-actions button {
  border: 0;
  background: transparent;
  color: #3f454e;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.ghost-button {
  height: 48px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  color: var(--blue-strong);
  background: #fff;
  cursor: pointer;
}

.ghost-button.active {
  color: #067647;
  border-color: #98d9b6;
  background: #eff8f3;
}

.sidebar {
  background: #fff;
  border-right: 1px solid var(--soft-line);
  padding: 28px 20px 22px 0;
}

.nav-item {
  width: calc(100% - 8px);
  min-height: 58px;
  height: auto;
  display: flex;
  align-items: center;
  margin: 0 8px 1px 0;
  padding: 10px 26px;
  border: 0;
  border-radius: 0 24px 24px 0;
  background: transparent;
  color: #4b5563;
  font-size: 20px;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}

.nav-item.active {
  color: #0070f4;
  background: #bcd8f7;
  font-weight: 700;
}

.content {
  overflow: auto;
  padding: 26px 26px 34px;
}

.report-frame {
  width: min(1502px, 100%);
  min-height: calc(100vh - 108px);
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid #111827;
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.14);
}

.report-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: stretch;
  min-height: 80px;
  border-bottom: 1px solid #101828;
}

.report-title {
  display: flex;
  align-items: center;
  padding: 0 22px;
  font-size: 28px;
  font-weight: 500;
}

.score-row {
  display: flex;
  align-items: stretch;
  border-left: 1px solid #101828;
}

.score {
  min-width: 142px;
  padding: 10px 18px 8px;
  border-right: 1px solid #101828;
}

.score:last-child {
  border-right: 0;
}

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

.score strong {
  display: block;
  margin-top: 2px;
  font-size: 24px;
  font-weight: 400;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 0;
  border-bottom: 1px solid #101828;
}

.filter-box {
  min-height: 48px;
  padding: 9px 20px;
  border-right: 1px solid #cfd4dc;
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.12);
  background: #fff;
}

.filter-box:last-child {
  border-right: 0;
}

.filter-box span {
  display: block;
  font-weight: 700;
  font-size: 13px;
}

.filter-box em {
  display: block;
  margin-top: 8px;
  color: #9aa3af;
  font-style: normal;
  font-size: 12px;
}

.section-title {
  margin: 0;
  padding: 8px 4px;
  font-size: 16px;
  font-weight: 500;
  border-bottom: 1px solid #101828;
}

.grid {
  display: grid;
}

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

.grid.three {
  grid-template-columns: repeat(3, 1fr);
}

.grid.five {
  grid-template-columns: repeat(5, 1fr);
}

.cell {
  min-height: 382px;
  border-right: 1px solid #101828;
  border-bottom: 1px solid #101828;
  padding: 0;
}

.grid.two .cell {
  min-height: 382px;
}

.cell:last-child,
.grid.two .cell:nth-child(2n),
.grid.three .cell:nth-child(3n),
.grid.five .cell:nth-child(5n) {
  border-right: 0;
}

.chart-title {
  margin: 0;
  padding: 8px 4px 6px;
  font-size: 23px;
  font-weight: 500;
  line-height: 1.1;
}

.chart {
  width: 100%;
  height: 338px;
  padding: 0 6px 6px;
}

.chart.tall {
  height: 340px;
}

.chart.short {
  height: 178px;
}

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

.treemap-chart {
  height: 338px;
}

.treemap-chart .treemap-html {
  width: 100%;
  height: 100%;
}

.treemap-html {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.treemap-total {
  position: relative;
  height: 32px;
  border-radius: 4px;
  background: #d9d9d9;
  color: #3f454e;
  font-size: 15px;
  font-weight: 700;
  line-height: 32px;
  text-align: center;
}

.treemap-scroll {
  position: absolute;
  top: -4px;
  right: 6px;
  width: 116px;
  height: 6px;
  border: 1px solid #aab5c2;
  border-radius: 999px;
  background: #d9edf9;
}

.treemap-scroll b {
  display: block;
  width: 50%;
  height: 100%;
  margin-left: auto;
  border-radius: inherit;
  background: #4285f4;
}

.treemap-body {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
}

.treemap-block {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid #fff;
  border-radius: 4px;
  padding: 0 9px;
  color: #1f2937;
  font-weight: 400;
  line-height: 1.2;
  text-align: center;
}

.treemap-block.primary {
  font-weight: 700;
}

.treemap-block span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0;
  pointer-events: none;
  user-select: none;
}

.chart svg text {
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

.legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 6px 12px;
  color: #3d4450;
  font-size: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 28px;
  height: 4px;
  border-radius: 3px;
}

.metric-strip {
  display: flex;
  border-bottom: 1px solid #101828;
}

.metric-strip .score {
  border-right: 1px solid #101828;
  border-left: 0;
}

.source-status {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 38px;
  padding: 8px 16px;
  border-bottom: 1px solid #101828;
  background: #f8fbff;
  color: #344054;
  font-size: 13px;
}

.source-status strong {
  color: #111827;
}

.source-status.ready {
  background: #eff8f3;
}

.source-status.pending {
  background: #fff8eb;
}

.source-status.error {
  background: #fff1f3;
  color: #912018;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eaf2ff;
  color: #111827;
  font-weight: 700;
}

th,
td {
  padding: 8px 9px;
  border-bottom: 1px solid #f0f2f5;
  text-align: left;
  white-space: nowrap;
}

tbody tr:nth-child(even) {
  background: #f7f8fa;
}

.number {
  text-align: right;
}

.muted-note {
  color: var(--muted);
  font-size: 13px;
}

.heat-card {
  min-height: 90px;
  display: grid;
  place-items: center;
  color: #17324d;
  border: 1px solid #d6e4f5;
  background: #edf6ff;
  font-weight: 700;
}

.kpi-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid #101828;
}

.kpi-board .score {
  border-right: 1px solid #101828;
}

.connect-panel {
  padding: 18px 22px;
  border-bottom: 1px solid #101828;
  background: #fbfcff;
}

.connect-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 12px;
}

.connect-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  background: #fff;
}

.connect-card strong {
  display: block;
  margin-bottom: 8px;
}

.placeholder-code {
  padding: 8px;
  background: #f3f5f8;
  border-radius: 4px;
  color: #344054;
  font-family: Consolas, monospace;
  font-size: 12px;
}

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

  .topbar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
  }

  .top-actions,
  .site-tabs,
  .sidebar nav {
    flex-wrap: wrap;
  }

  .top-actions {
    margin-left: 0;
  }

  .sidebar {
    grid-row: 2;
    padding: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--soft-line);
    overflow-x: auto;
  }

  .sidebar nav {
    display: flex;
    gap: 6px;
  }

  .nav-item {
    width: auto;
    min-width: 128px;
    border-radius: 22px;
    padding: 0 16px;
  }

  .content {
    padding: 12px;
  }

  .report-header,
  .toolbar,
  .grid.two,
  .grid.three,
  .grid.five,
  .connect-grid,
  .kpi-board {
    grid-template-columns: 1fr;
  }

  .score-row,
  .metric-strip,
  .source-status {
    flex-wrap: wrap;
    border-left: 0;
  }

  .cell,
  .grid.two .cell:nth-child(2n),
  .grid.three .cell:nth-child(3n),
  .grid.five .cell:nth-child(5n) {
    border-right: 0;
  }
}
