/* ── reset & base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: #222;
  background: #fafafa;
  display: flex;
  flex-direction: column;
}

/* ── toolbar ──────────────────────────────────────────────────────── */
#toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}
.app-title { font-weight: 700; font-size: 16px; margin-right: 6px; }
.back-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px;
  background: #f0f0f0; color: #444; text-decoration: none;
  font-size: 16px; font-weight: 700; flex-shrink: 0;
  transition: background 0.15s;
}
.back-btn:hover { background: #ddd; }
#toolbar label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #555; }
#toolbar select, #toolbar input[type="number"] {
  padding: 4px 8px; border: 1px solid #ccc; border-radius: 4px;
  font-size: 13px; background: #fff;
}
#toolbar input[type="number"] { width: 64px; }
.stats { font-size: 12px; color: #888; margin-left: auto; }

/* ── metrics bar ──────────────────────────────────────────────────── */
#metrics-bar {
  display: flex;
  gap: 0;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.metric-pill {
  text-align: center;
  padding: 4px 14px;
  font-size: 12px;
  line-height: 1.3;
}
.metric-pill .val { font-size: 20px; font-weight: 700; }
.metric-pill .lbl { color: #888; }

/* ── main ─────────────────────────────────────────────────────────── */
#main {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px 40px;
}
.section-heading {
  font-size: 15px;
  font-weight: 700;
  margin: 16px 0 8px;
  color: #444;
}

/* ── matched pair card ────────────────────────────────────────────── */
.pair-card {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  margin-bottom: 6px;
  background: #fff;
  overflow: hidden;
}
.pair-header {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  cursor: pointer;
  user-select: none;
  gap: 8px;
  font-size: 13px;
  transition: background 0.12s;
}
.pair-header:hover { background: #fafafa; }
.pair-header .arrow {
  flex-shrink: 0; font-size: 10px; color: #999;
  transition: transform 0.2s;
}
.pair-card.open .pair-header .arrow { transform: rotate(90deg); }
.col-header-row {
  display: flex; padding: 4px 14px 4px 34px; gap: 8px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: #888; margin-bottom: 2px;
}
.col-h { flex: 1; }
.col-h-pred { color: #c4163f; }
.col-h-ref  { color: #2e8a3a; }
.pair-header .pred-title { flex: 1; font-weight: 600; }
.pair-header .sep { color: #ccc; flex-shrink: 0; }
.pair-header .ref-title { flex: 1; color: #555; }
.pair-header .score-badge {
  flex-shrink: 0; padding: 2px 8px; border-radius: 4px;
  font-size: 12px; font-weight: 700;
}

.pair-body {
  display: none;
  border-top: 1px solid #f0f0f0;
}
.pair-card.open .pair-body { display: flex; }
.pair-side {
  flex: 1;
  padding: 10px 16px;
  font-size: 12.5px;
  line-height: 1.55;
}
.pair-side + .pair-side { border-left: 2px solid rgba(128,128,128,0.15); }
.pair-side .side-label {
  font-size: 11px; margin-bottom: 6px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px; padding: 2px 6px;
  border-radius: 3px; display: inline-block;
}
.pair-side:first-child .side-label { background: #e6194b18; color: #c4163f; }
.pair-side:last-child  .side-label { background: #3cb44b18; color: #2e8a3a; }

/* ── single policy card (unmatched) ───────────────────────────────── */
.policy-card {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  margin-bottom: 6px;
  background: #fff;
  overflow: hidden;
}
.policy-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; cursor: pointer; font-size: 13px;
  transition: background 0.12s;
}
.policy-header:hover { background: #fafafa; }
.policy-header .arrow { flex-shrink: 0; font-size: 10px; color: #999; transition: transform 0.2s; }
.policy-card.open .policy-header .arrow { transform: rotate(90deg); }
.policy-header .icon { flex-shrink: 0; }
.policy-header .title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.policy-detail {
  display: none;
  padding: 6px 16px 12px 36px;
  font-size: 12.5px; line-height: 1.55;
  border-top: 1px solid #f0f0f0;
}
.policy-card.open .policy-detail { display: block; }

/* shared field styling */
.field { margin-bottom: 3px; }
.field-label { font-weight: 600; color: #555; }
.area-badge { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.excerpt { margin-top: 6px; padding: 6px 10px; background: #f7f7f7; border-radius: 4px; font-size: 12px; color: #555; max-height: 120px; overflow-y: auto; }
.match-hl { font-weight: 700; }

/* unmatched columns */
.unmatched-cols { display: flex; gap: 20px; }
.unmatched-col { flex: 1; min-width: 0; }

/* ── loading ──────────────────────────────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center; height: 80px; color: #999; font-size: 13px; }
