:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #657188;
  --line: #d9dfeb;
  --brand: #2367d8;
  --brand-dark: #174da8;
  --ok: #11845b;
  --bad: #c43d32;
  --warn: #a76500;
  --soft-blue: #e9f1ff;
  --soft-green: #e7f6ef;
  --soft-red: #ffedeb;
  --soft-amber: #fff4dd;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
textarea {
  font: inherit;
}

.topbar {
  min-height: 112px;
  padding: 24px clamp(18px, 4vw, 44px);
  color: #ffffff;
  background: linear-gradient(120deg, #153d78, #2367d8 48%, #168269);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0;
  opacity: 0.82;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

h3 {
  margin-bottom: 12px;
  font-size: 15px;
}

.status {
  min-width: 118px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 6px;
  text-align: center;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.12);
}

.workspace {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px clamp(14px, 3vw, 32px) 40px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(32, 48, 76, 0.08);
}

.source-panel {
  padding: 18px;
}

.monitor-panel,
.history-panel {
  padding: 18px;
  margin-bottom: 16px;
}

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

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

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

.source-column {
  display: grid;
  gap: 10px;
  min-width: 0;
}

label {
  color: #334055;
  font-size: 13px;
  font-weight: 650;
}

.inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #ffffff;
  outline: none;
}

input {
  height: 38px;
  padding: 0 11px;
}

textarea {
  min-height: 210px;
  resize: vertical;
  padding: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
}

input:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(35, 103, 216, 0.14);
}

button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 13px;
  color: #1f2b3d;
  background: #ffffff;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: #aab6c9;
  background: #f8fafc;
}

button:disabled {
  color: #99a3b4;
  cursor: not-allowed;
}

.primary {
  color: #ffffff;
  border-color: var(--brand);
  background: var(--brand);
}

.primary:hover:not(:disabled) {
  border-color: var(--brand-dark);
  background: var(--brand-dark);
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 18px;
}

.file-target {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  border: 1px dashed #aeb9ca;
  border-radius: 6px;
  color: var(--brand);
  background: #f8fbff;
  cursor: pointer;
}

.file-target input {
  display: none;
}

.snapshot-meta {
  min-height: 38px;
  padding: 9px 11px;
  border-radius: 6px;
  color: var(--muted);
  background: #f2f5fa;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

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

.metric-card {
  min-height: 98px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 27px;
  line-height: 1;
}

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

.results-panel {
  overflow: hidden;
  margin-bottom: 16px;
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  white-space: nowrap;
}

.tab.active {
  color: #ffffff;
  border-color: #2f6fbd;
  background: #2f6fbd;
}

.result-view {
  min-height: 320px;
  padding: 18px;
}

.empty-state {
  display: grid;
  place-items: center;
  color: var(--muted);
}

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

.diff-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.diff-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.added .diff-title {
  background: var(--soft-green);
  color: var(--ok);
}

.removed .diff-title {
  background: var(--soft-red);
  color: var(--bad);
}

.neutral .diff-title {
  background: var(--soft-blue);
  color: #245792;
}

.diff-list {
  max-height: 430px;
  margin: 0;
  padding: 8px 0;
  overflow: auto;
  list-style: none;
}

.diff-list li {
  padding: 7px 12px;
  border-bottom: 1px solid #edf0f5;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.diff-list li:last-child {
  border-bottom: 0;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #e8edf5;
  text-align: left;
  font-size: 13px;
}

th {
  color: #344156;
  background: #f3f6fb;
}

.delta-pos {
  color: var(--ok);
}

.delta-neg {
  color: var(--bad);
}

.snapshot-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.snapshot-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.snapshot-card p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.history-view {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) repeat(4, minmax(76px, auto));
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  font-size: 13px;
}

.history-item strong {
  display: block;
  margin-bottom: 3px;
  overflow-wrap: anywhere;
}

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

.pill {
  display: inline-flex;
  justify-content: center;
  min-width: 72px;
  padding: 5px 8px;
  border-radius: 999px;
  color: #334055;
  background: #edf2f8;
  font-size: 12px;
}

.pill.good {
  color: var(--ok);
  background: var(--soft-green);
}

.pill.bad {
  color: var(--bad);
  background: var(--soft-red);
}

.library-view {
  display: grid;
  gap: 14px;
}

.highlight-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.highlight-panel.changed {
  border-color: #f0b4ad;
  background: #fff7f6;
}

.highlight-panel.stable {
  border-color: #b9dfcd;
  background: #f4fbf7;
}

.highlight-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.highlight-head h3 {
  margin-bottom: 4px;
}

.highlight-head p,
.library-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.highlight-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.highlight-metric {
  min-height: 72px;
  padding: 10px;
  border: 1px solid rgba(217, 223, 235, 0.8);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.highlight-metric strong {
  display: block;
  font-size: 22px;
  line-height: 1;
}

.highlight-metric span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

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

.highlight-list {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.highlight-list ul {
  max-height: 180px;
  margin: 8px 0 0;
  padding-left: 18px;
  overflow: auto;
  color: #2a3547;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.highlight-empty {
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
  color: var(--ok);
  background: rgba(255, 255, 255, 0.7);
}

.library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.library-toolbar h3 {
  margin-bottom: 4px;
}

.open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  color: var(--brand);
  text-decoration: none;
  white-space: nowrap;
}

.library-frame {
  width: 100%;
  height: min(76vh, 860px);
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

@media (max-width: 920px) {
  .topbar,
  .source-grid,
  .diff-grid,
  .snapshot-row,
  .monitor-grid,
  .history-item,
  .highlight-detail {
    grid-template-columns: 1fr;
  }

  .library-toolbar {
    display: grid;
  }

  .topbar {
    display: grid;
  }

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

@media (max-width: 560px) {
  .inline,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
  }

  button {
    width: 100%;
  }
}
