:root {
  color-scheme: light;
  --bg: #eef2f6;
  --panel: #ffffff;
  --panel-soft: #f7f9fb;
  --text: #17202a;
  --muted: #6b7684;
  --line: #d9e0e8;
  --accent: #126f73;
  --accent-dark: #0b5558;
  --accent-soft: #dff5f2;
  --warn: #a16207;
  --warn-soft: #fef3c7;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --ok: #057a55;
  --ok-soft: #d1fadf;
  --shadow: 0 18px 48px rgba(18, 32, 45, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.65), rgba(238, 242, 246, 0.88)),
    var(--bg);
  color: var(--text);
  font-family:
    "Inter", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.is-hidden {
  display: none !important;
}

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

.auth-card {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid rgba(217, 224, 232, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
}

.user-bar span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.user-bar strong {
  display: block;
  margin-top: 2px;
}

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

.query-panel,
.report-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(217, 224, 232, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.query-panel {
  position: sticky;
  top: 24px;
  padding: 22px;
}

.report-panel {
  padding: 22px;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: 30px;
  line-height: 1.18;
}

h2 {
  font-size: 26px;
}

h3 {
  font-size: 18px;
}

.subcopy {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.query-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.query-toolbar {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) 92px 82px 92px;
  gap: 10px;
  align-items: end;
}

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

.field span,
.platform-field legend {
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

textarea {
  resize: vertical;
  min-height: 96px;
  padding: 12px;
  line-height: 1.6;
}

.bulk-textarea {
  min-height: 310px;
  font-size: 14px;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(18, 111, 115, 0.12);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 12px;
}

.counter-chip {
  display: grid;
  align-content: center;
  min-height: 42px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.counter-chip strong {
  line-height: 1;
  font-size: 18px;
}

.counter-chip span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.platform-field {
  margin: 0;
  padding: 0;
  border: 0;
}

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

.platform-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

.platform-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.actions,
.header-actions {
  display: flex;
  gap: 10px;
}

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary-button,
.ghost-button {
  min-height: 44px;
  padding: 0 18px;
}

.primary-button {
  flex: 1;
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.ghost-button,
.icon-button {
  background: #e8eef3;
  color: #243244;
}

.icon-button {
  min-width: 58px;
  height: 38px;
  padding: 0 12px;
}

.report-header,
.section-title,
.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.stat-card {
  min-height: 86px;
  padding: 16px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.progress-wrap {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.progress-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.progress-track {
  height: 10px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef3;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #2a9d8f);
  transition: width 0.25s ease;
}

.matrix-section,
.details-section,
.history-section {
  margin-top: 18px;
}

.section-title {
  margin-bottom: 10px;
}

.section-title span {
  color: var(--muted);
  font-size: 13px;
}

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

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f3f6f9;
  color: #344054;
  font-weight: 800;
}

tr:last-child td {
  border-bottom: 0;
}

.query-cell {
  min-width: 220px;
  font-weight: 800;
}

.status-pill,
.hit-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-hit {
  background: var(--ok-soft);
  color: var(--ok);
}

.status-miss {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-pending {
  background: var(--warn-soft);
  color: var(--warn);
}

.empty-state {
  height: 220px;
  color: var(--muted);
  text-align: center;
}

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

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 110px 130px 96px;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.history-item:hover {
  background: var(--panel-soft);
}

.history-item span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-item {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(100px, 0.8fr) 96px 86px 136px 150px;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.detail-title,
.detail-meta {
  min-width: 0;
}

.detail-title strong,
.detail-title span,
.detail-meta strong,
.detail-meta span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-title span,
.detail-meta span,
.detail-hits,
.muted-link {
  color: var(--muted);
  font-size: 12px;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-button {
  height: 34px;
  padding: 0 12px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.view-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  background: #e8eef3;
  color: #243244;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

dialog {
  width: min(760px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(20, 30, 41, 0.45);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 10px;
}

.close-button {
  width: 34px;
  height: 34px;
  background: #e8eef3;
  color: #243244;
  font-size: 22px;
  line-height: 1;
}

.dialog-body {
  padding: 0 18px 18px;
}

.dialog-label {
  margin: 16px 0 8px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

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

.hit-pill {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

pre {
  max-height: 360px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101828;
  color: #e6edf3;
  white-space: pre-wrap;
  line-height: 1.6;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .query-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
  }

  .query-panel,
  .report-panel {
    padding: 16px;
  }

  h1 {
    font-size: 24px;
  }

  .query-toolbar,
  .field-row,
  .stats-grid,
  .detail-item,
  .history-item {
    grid-template-columns: 1fr;
  }

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

  .report-header,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }
}
