:root {
  color-scheme: light;
  --bg: #f4efe6;
  --panel: #fffdf9;
  --panel-soft: #fbf7f0;
  --text: #1b2a23;
  --muted: #4c5d55;
  --line: rgba(27, 42, 35, 0.14);
  --good: #20473b;
  --warn: #b26e34;
  --update: #20473b;
  --danger: #b42318;
  --accent-soft: rgba(178, 110, 52, 0.12);
  --shadow: 0 12px 30px rgba(17, 28, 24, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 243, 0.78);
  box-shadow: var(--shadow);
}

h1, h2, p { margin: 0; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 17px; }

p, .panel-head span, .metric span, .muted-label {
  color: var(--muted);
  font-size: 13px;
}

.badge {
  min-width: 96px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  text-align: center;
  font-weight: 700;
  background: var(--panel);
}
.badge.ok      { color: var(--good);   border-color: #9bd4bd; }
.badge.updates { color: var(--warn); border-color: rgba(178, 110, 52, 0.34); }
.badge.warning { color: var(--warn);   border-color: #f0b58c; }

.bank-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.metric-mode {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.seg-btn,
.entity-search button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.seg-btn {
  min-height: 34px;
  padding: 6px 12px;
}

.seg-btn.active {
  background: var(--update);
  border-color: var(--update);
  color: #fff;
  font-weight: 700;
}

.metric-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

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

.metric, .bank, .panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric { padding: 16px; }
.metric strong { display: block; margin-top: 8px; font-size: 30px; }

.panel { margin-top: 14px; padding: 16px; }

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

.bank {
  padding: 14px;
  display: grid;
  /* Row 1: bank code (固定一行)
     Row 2: bank fullname (固定 4em 高度, 可换行 / 截断, 7 张卡片这一行一律占同样空间)
     Row 3: big count number
     Row 4: suffix */
  grid-template-rows: auto 4em auto auto;
  row-gap: 4px;
  align-content: start;
}

.bank-head {
  display: contents;
}

.bank-code {
  display: block;
  color: var(--good);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.5px;
  line-height: 1.1;
}

.bank-fullname {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
}

.bank-count {
  display: block;
  margin-top: 2px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.05;
}

.bank small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
}

/* Period tabs */
.period-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 6px 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tab-btn:hover {
  background: #efe6da;
  color: var(--text);
}
.tab-btn.active {
  background: var(--update);
  border-color: var(--update);
  color: #fff;
  font-weight: 600;
}

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

/* Period summary row */
.period-summary { margin-bottom: 14px; }

/* Change hint bar */
.change-hint-bar { margin-bottom: 12px; }
.change-hint {
  font-size: 13px;
  color: var(--muted);
}
.change-hint.ok-hint { color: var(--good); }
.change-hint strong { color: var(--text); }

.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.filters label {
  display: grid;
  gap: 4px;
  min-width: 210px;
  color: var(--muted);
  font-size: 12px;
}

.filters label:first-child {
  min-width: 360px;
}

.filters select,
.entity-search input {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.filters select {
  padding: 5px 8px;
}

.hidden {
  display: none;
}

/* Change cards */
.changes { display: grid; gap: 10px; }

.change-item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--update);
  border-radius: 6px;
  padding: 12px;
  background: var(--panel);
}
.change-item.removed { border-left-color: var(--danger); }
.change-item.changed { border-left-color: var(--warn); }

.change-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 700;
  align-items: baseline;
  flex-wrap: wrap;
}

.change-headline {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.change-label {
  white-space: nowrap;
}

.bank-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--good);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  line-height: 1.5;
  vertical-align: middle;
}

.change-item.removed .bank-pill { background: var(--danger); }
.change-item.changed .bank-pill { background: var(--warn); }

.entity-name-inline {
  font-weight: 700;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
}

.period-current {
  color: var(--text);
  white-space: nowrap;
  font-weight: 500;
  font-size: 13px;
}

.change-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.change-diff {
  display: grid;
  gap: 6px;
  margin-top: 4px;
  padding: 8px;
  background: var(--accent-soft);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text);
}

.diff-row {
  display: grid;
  grid-template-columns: minmax(76px, 140px) minmax(0, 1fr);
  gap: 8px;
}

.diff-label {
  color: var(--text);
  font-weight: 700;
}

.diff-values {
  min-width: 0;
  overflow-wrap: anywhere;
}

.vertical-diff {
  display: grid;
  gap: 4px;
}

.vertical-line {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}

.diff-side {
  color: var(--muted);
  font-weight: 700;
}

.diff-content,
.period-parts {
  min-width: 0;
  overflow-wrap: anywhere;
}

.period-parts {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.period-join,
.unchanged-token {
  color: var(--text);
}

.changed-token {
  color: #b42318;
  font-weight: 700;
}

.delta-list {
  display: grid;
  gap: 4px;
}

.delta-line {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
  color: #b42318;
  font-weight: 700;
}

.delta-tag {
  border-radius: 4px;
  padding: 0 4px;
  text-align: center;
  font-weight: 700;
}

.delta-removed .delta-tag {
  background: #ffe2d6;
  color: #b42318;
}

.delta-added .delta-tag {
  background: #ffe2d6;
  color: #b42318;
}

.muted-diff {
  color: var(--muted);
  background: #f7f9fb;
}

.entity-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  color: var(--muted);
}

.entity-facts span:first-child {
  color: var(--text);
  font-weight: 600;
}

.entity-box {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 14px 0;
  padding: 14px 0;
}

.compact-head {
  margin-bottom: 8px;
}

.compact-head h2 {
  font-size: 16px;
}

.entity-search {
  display: flex;
  gap: 8px;
}

.entity-search input {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
}

.entity-search button {
  min-width: 88px;
  padding: 6px 14px;
  background: var(--update);
  border-color: var(--update);
  color: #fff;
  font-weight: 700;
}

.entity-timeline {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.timeline-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 10px;
}

.timeline-date,
.timeline-desc,
.timeline-empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.timeline-title {
  margin-top: 4px;
  font-weight: 700;
}

/* Comparison errors */
.comparison-errors {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}
.comp-error {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
}

a { color: var(--update); }

@media (max-width: 900px) {
  .bank-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .topbar, .panel-head, .change-title {
    align-items: flex-start;
    flex-direction: column;
  }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bank-grid     { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .entity-search { flex-direction: column; }
}
