:root {
  --red:     #e53e3e;
  --blue:    #3182ce;
  --green:   #38a169;
  --red-bg:  #fff5f5;
  --blue-bg: #ebf8ff;
  --green-bg:#f0fff4;
  --border:  #e2e8f0;
  --text:    #1a202c;
  --muted:   #718096;
  --surface: #ffffff;
  --page-bg: #f7fafc;
  --radius:  12px;
  --shadow:  0 1px 3px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  background: var(--page-bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 24px 16px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.tagline {
  font-size: 13px;
  color: var(--muted);
  max-width: 480px;
}

/* ── Main ────────────────────────────────────────────── */
main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 28px auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Input card ──────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px 24px;
}

.columns {
  display: flex;
  gap: 0;
  align-items: stretch;
}

.column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.column-divider {
  width: 1px;
  background: var(--border);
  margin: 0 20px;
  flex-shrink: 0;
}

label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.label-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-red  { background: var(--red); }
.dot-blue { background: var(--blue); }

textarea {
  width: 100%;
  height: 220px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  resize: vertical;
  font-family: 'JetBrains Mono', 'Fira Mono', monospace;
  font-size: 12.5px;
  line-height: 1.7;
  background: #fdfdfd;
  color: var(--text);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}

textarea:focus {
  border-color: #a0aec0;
  box-shadow: 0 0 0 3px rgba(66,153,225,.12);
}

/* ── Button ──────────────────────────────────────────── */
.btn-row {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

button#compareBtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 36px;
  background: #2b6cb0;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s, transform .1s, box-shadow .18s;
  box-shadow: 0 2px 6px rgba(43,108,176,.25);
}

button#compareBtn:hover {
  background: #2c5282;
  box-shadow: 0 4px 12px rgba(43,108,176,.32);
}

button#compareBtn:active {
  transform: translateY(1px);
}

/* ── Results ─────────────────────────────────────────── */
#result {
  display: none;
  flex-direction: column;
  gap: 16px;
}

#result.visible { display: flex; }

.result-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-sum {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.diff-value { color: var(--red); }
.diff-zero  { color: var(--green); }

.result-stats {
  display: flex;
  gap: 20px;
  font-size: 12.5px;
  color: var(--muted);
  flex-wrap: wrap;
}

.result-stats b { color: var(--text); }

.alert {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-found {
  background: var(--green-bg);
  border-left: 3px solid var(--green);
  color: #276749;
}

.alert-not-found {
  background: #fffbeb;
  border-left: 3px solid #d69e2e;
  color: #744210;
}

/* ── Three-table layout ──────────────────────────────── */
.tables-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.unmatched-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.unmatched-row .table-card { flex: 1; min-width: 0; }

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.table-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.label-red   { color: var(--red); }
.label-green { color: var(--green); }
.label-blue  { color: var(--blue); }

.table-count {
  font-size: 11px;
  font-weight: 600;
  background: #edf2f7;
  color: #4a5568;
  border-radius: 20px;
  padding: 1px 8px;
}

.empty-note {
  padding: 14px;
  font-size: 12.5px;
  color: #a0aec0;
  font-style: italic;
  text-align: center;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.result-table thead th {
  background: #f7fafc;
  padding: 6px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}

.result-table thead th:first-child {
  width: 44px;
  text-align: center;
}

.result-table tbody tr:hover { background: #f7fafc; }

.result-table td {
  padding: 5px 12px;
  border-bottom: 1px solid #f0f4f8;
  vertical-align: middle;
}

.result-table tbody tr:last-child td { border-bottom: none; }

.result-table td.row-num {
  text-align: center;
  color: #cbd5e0;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
}

.val-col1 { color: var(--red);   font-weight: 500; font-family: 'JetBrains Mono', monospace; }
.val-col2 { color: var(--blue);  font-weight: 500; font-family: 'JetBrains Mono', monospace; }
.val-match { color: #2d3748;     font-weight: 500; font-family: 'JetBrains Mono', monospace; }

/* ── Footer ──────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  text-align: center;
  padding: 12px 24px;
  font-size: 12px;
  color: #a0aec0;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 680px) {
  .header-inner { gap: 10px; }
  .tagline { display: none; }

  .columns {
    flex-direction: column;
    gap: 16px;
  }

  .column-divider { display: none; }

  .unmatched-row {
    flex-direction: column;
  }

  .unmatched-row .table-card { width: 100%; }
}
