:root {
  --bg-0: #f6efe4;
  --bg-1: #fffbf5;
  --ink: #1f1a16;
  --ink-soft: #5e5348;
  --line: #d8c8b4;
  --panel: #fffaf2;
  --accent: #0d7a6b;
  --accent-2: #b5681f;
  --diff: #ffe1c2;
  --missing: #ffd4d4;
  --same: #edf8f4;
  --shadow: 0 14px 40px rgba(74, 44, 15, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% -10%, #ffe7c9 0%, transparent 40%),
    radial-gradient(circle at 100% 0%, #f8d7be 0%, transparent 35%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 55%);
}

.hero {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 20px 18px;
}

.hero__badge {
  display: inline-block;
  padding: 6px 10px;
  border: 1px solid #d4b89c;
  border-radius: 999px;
  font-size: 12px;
  color: #6e4a2b;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: #fff3e3;
}

h1,
h2 {
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  margin: 10px 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
}

.hero p {
  margin: 0;
  color: var(--ink-soft);
  max-width: 760px;
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.metric {
  background: #fff6ea;
  border: 1px solid #e7c8a8;
  border-radius: 12px;
  padding: 8px 12px;
  min-width: 160px;
}

.metric strong {
  display: block;
  font-family: "Space Grotesk", sans-serif;
  font-size: 20px;
}

.legend {
  max-width: 1400px;
  margin: 6px auto 0;
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.legend__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #4c4035;
}

.swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid #c9b39b;
}

.swatch--diff {
  background: var(--diff);
}

.swatch--missing {
  background: var(--missing);
}

.swatch--same {
  background: var(--same);
}

.comparison-wrap {
  max-width: 1400px;
  margin: 12px auto 20px;
  padding: 0 20px 26px;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel__head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, #fff2df 0%, #fff9ef 100%);
}

.panel__head h2 {
  margin: 0;
  font-size: 22px;
}

.panel__head p {
  margin: 4px 0 0;
  color: #6c5b4a;
  font-size: 14px;
}

.grid-shell {
  height: min(74vh, 920px);
  overflow: auto;
  position: relative;
  border-radius: 8px;
  border: 1px solid var(--line);
}

/* Đảm bảo bảng có bố cục cố định và hàng có chiều cao bằng nhau */
.grid-shell table {
  table-layout: fixed;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1200px; 
  font-size: 13px;
}

.grid-shell tr {
  height: 48px;
}

.grid-shell th,
.grid-shell td {
  padding: 8px 12px;
  line-height: 1.4;
  height: 48px; /* Cố định chiều cao ô */
  max-width: 0; /* Box-sizing cho text-overflow hoạt động tốt */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap; /* Tránh xuống dòng làm lệch hàng */
  border-bottom: 1px solid #e5d6c7;
  border-right: 1px solid #eedfce;
  vertical-align: middle; 
  box-sizing: border-box; /* Đảm bảo padding không làm tăng chiều cao */
}

/* Cột đầu tiên */
.grid-shell th:first-child,
.grid-shell td:first-child {
  width: 72px; 
  min-width: 72px;
}

/* Tiêu đề bảng dính (Sticky Header) */
.grid-shell th {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #f6e8d7;
  color: #3e2f23;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05); 
}

/* Gắn cột đầu tiên theo chiều ngang (sticky left) */
.grid-shell tr td:first-child,
.grid-shell tr th:first-child {
  position: sticky;
  left: 0;
  z-index: 11;
  background: #fff7ec;
}

/* Đặc quyền cho góc */
.grid-shell tr th:first-child {
  z-index: 12;
  background: #f6e8d7;
}

/* Hover bảng */
.grid-shell tr:hover td {
  background: #fff5e7;
}

/* Bảng tóm tắt phía trên (Summary Table) */
.summary-table-wrap {
  margin-top: 14px;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border: 1px solid #eadece;
}

.summary-table tr {
  border-bottom: 1px solid #f0e6d8;
}

.summary-table tr:last-child {
  border-bottom: none;
}

.summary-table th,
.summary-table td {
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}

.summary-table th {
  background: #fcf8f2;
  color: #5e5348;
  font-weight: 600;
  width: 38%;
  border-right: 1px solid #f0e6d8;
}

.summary-table td {
  color: #1f1a16;
}

.cell--diff {
  background: var(--diff) !important;
}

.cell--same {
  background: var(--same);
}

/* Lấp đầy nội dung bằng ô xám mờ */
.row--missing td {
  background-color: #f0ede5 !important;
  color: transparent !important;
  pointer-events: none;
}

.error-box {
  margin: 16px;
  padding: 14px;
  border: 1px solid #e7b0b0;
  background: #fff0f0;
  border-radius: 12px;
}

.error-box code {
  background: #f7e5e5;
  padding: 2px 6px;
  border-radius: 6px;
}

@media (max-width: 1100px) {
  .comparison-wrap {
    grid-template-columns: 1fr;
  }

  .grid-shell {
    height: 62vh;
  }
}
