:root {
  --bg: #f4f1ea;
  --card: #fffdf8;
  --line: #d9d2c6;
  --ink: #1d1a16;
  --muted: #6a6258;
  --accent: #af3b2d;
  --accent-dark: #892b20;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at top right, rgba(175, 59, 45, 0.12), transparent 28%),
    linear-gradient(180deg, #efe7d8 0%, var(--bg) 22%, #f7f4ef 100%);
  color: var(--ink);
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.88);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
}

.topbar-inner,
.page {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 68px;
}

.brand,
.nav a {
  color: var(--ink);
  text-decoration: none;
}

.brand {
  font-size: 1.1rem;
  font-weight: 700;
}

.nav {
  display: flex;
  gap: 16px;
}

.page {
  padding: 32px 0 48px;
}

.hero h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 3rem);
}

.hero p {
  color: var(--muted);
  max-width: 760px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  margin-top: 20px;
  box-shadow: 0 10px 30px rgba(29, 26, 22, 0.05);
}

.search-form,
.upload-form,
.mapping-form {
  display: grid;
  gap: 16px;
}

.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  background: #fff;
}

.summary-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-top: 20px;
}

.stat-card {
  margin-top: 0;
}

.stat-label,
.muted {
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
}

.warning {
  margin: 0;
  color: var(--accent);
}

.success {
  margin: 0;
  color: #1f6b45;
}

.search-form {
  grid-template-columns: 1fr auto;
}

input[type="text"],
input[type="number"],
input[type="file"],
select,
button {
  font: inherit;
}

input[type="text"],
input[type="number"],
select,
input[type="file"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.product-card {
  display: grid;
  gap: 16px;
}

.product-main {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 8px;
  font-size: 0.75rem;
}

.metrics {
  display: grid;
  gap: 8px;
  min-width: 180px;
  text-align: right;
}

.related ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.mapping-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.preset-row {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.preset-label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  min-width: 260px;
}

.sample-table-wrap {
  overflow-x: auto;
}

.empty {
  color: var(--muted);
}

@media (max-width: 720px) {
  .search-form {
    grid-template-columns: 1fr;
  }

  .product-main {
    flex-direction: column;
  }

  .metrics {
    text-align: left;
    min-width: 0;
  }

  .topbar-inner {
    flex-direction: column;
    justify-content: center;
    padding: 12px 0;
    gap: 8px;
  }
}
