:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --text: #17202a;
  --muted: #5f6f82;
  --line: #d7e0ea;
  --primary: #126d75;
  --primary-2: #0f5961;
  --danger: #b42318;
  --warning: #a65f00;
  --good: #207344;
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 32px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: 0;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.icon-button,
.text-button,
.segmented,
.search-row button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  min-height: 38px;
}

.icon-button {
  width: 40px;
  font-size: 20px;
}

main {
  padding: 22px 32px 42px;
}

.search-band {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.search-form label {
  display: block;
  margin-bottom: 10px;
  font-weight: 700;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 138px 168px 150px;
  gap: 10px;
  align-items: end;
}

.search-row input,
.search-row select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
}

.days-field {
  display: block;
}

.search-form .days-field {
  margin-bottom: 0;
  font-weight: 600;
}

.days-field span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.days-field input {
  padding: 0 10px;
}

.search-row button {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 700;
}

.search-row button:hover {
  background: var(--primary-2);
}

.quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.keyword-chip {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  min-height: 30px;
}

.chip-select,
.chip-delete {
  min-height: 30px;
  border: 0;
  background: transparent;
  color: inherit;
}

.chip-select {
  padding: 5px 10px;
  font-weight: 700;
}

.chip-delete {
  width: 30px;
  border-left: 1px solid rgba(18, 109, 117, 0.16);
  font-size: 18px;
  line-height: 1;
}

.chip-delete:hover {
  background: rgba(180, 35, 24, 0.1);
  color: var(--danger);
}

.scan-progress {
  margin: 16px 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.progress-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

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

.progress-heading strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

.progress-heading em {
  font-style: normal;
  font-weight: 700;
  color: var(--primary);
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 180ms ease;
}

.progress-intent {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-left: 3px solid var(--primary);
  background: #eef8f7;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.progress-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.progress-stats div {
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f9fbfd;
}

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

.progress-stats strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.status-strip div,
.insight-panel,
.report-panel,
.results-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-strip div {
  padding: 14px;
}

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

.status-strip strong {
  display: block;
  margin-top: 5px;
  font-size: 19px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  align-items: start;
}

.report-panel,
.insight-panel,
.results-section {
  padding: 18px;
}

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

h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
}

h3 {
  margin-top: 18px;
  font-size: 15px;
}

.text-button {
  padding: 0 12px;
}

.summary-box {
  border-left: 4px solid var(--primary);
  background: #eef7f5;
  padding: 12px;
  border-radius: 6px;
  color: #153f43;
  line-height: 1.6;
}

.report-records {
  display: grid;
  gap: 10px;
}

.records-empty {
  border: 1px dashed var(--line);
  background: #f9fbfd;
  border-radius: 8px;
  padding: 22px;
  color: var(--muted);
}

.records-empty strong {
  display: block;
  color: var(--text);
  margin-bottom: 6px;
}

.records-empty p {
  margin: 0;
  line-height: 1.55;
}

.report-record {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 8px 14px;
  width: 100%;
  min-height: 82px;
  padding: 13px 14px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.report-record:hover,
.report-record.active {
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(18, 109, 117, 0.12);
}

.record-main strong,
.record-main small,
.record-summary {
  display: block;
}

.record-main strong {
  font-size: 16px;
  margin-bottom: 5px;
}

.record-main small,
.record-summary {
  color: var(--muted);
}

.record-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.record-stats b {
  font-size: 18px;
}

.record-stats em {
  font-style: normal;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  background: #f9fbfd;
}

.record-summary {
  grid-column: 1 / -1;
  line-height: 1.45;
}

.report-detail-section {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.detail-meta {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.report-body {
  margin-top: 14px;
  line-height: 1.7;
}

.report-body h1,
.report-body h2,
.report-body h3 {
  margin: 18px 0 8px;
}

.report-body p {
  margin: 8px 0;
}

.metric-list {
  display: grid;
  gap: 10px;
}

.metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}

.metric span {
  color: var(--muted);
}

.metric strong {
  text-align: right;
}

.recommendations {
  margin: 10px 0 0;
  padding-left: 18px;
  line-height: 1.55;
}

.results-section {
  margin-top: 16px;
}

.filters {
  display: flex;
  gap: 8px;
}

.segmented {
  padding: 0 12px;
}

.segmented.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  border-top: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-weight: 700;
  background: #f9fbfd;
}

.title-cell strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

.title-cell p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  border: 1px solid var(--line);
  white-space: nowrap;
}

.badge.negative,
.badge.high {
  color: var(--danger);
  border-color: #f1b5ad;
  background: #fff1ef;
}

.badge.warning,
.badge.medium {
  color: var(--warning);
  border-color: #efd2a5;
  background: #fff7ea;
}

.badge.positive,
.badge.low {
  color: var(--good);
  border-color: #b9dfc8;
  background: #eefaf2;
}

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

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 12px 14px;
  background: #17202a;
  color: #fff;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .workspace-grid,
  .status-strip {
    grid-template-columns: 1fr;
  }

  .search-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar,
  main {
    padding-left: 16px;
    padding-right: 16px;
  }

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

  .report-record {
    grid-template-columns: 1fr;
  }

  .record-stats {
    flex-wrap: wrap;
  }

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