:root {
  --ink: #16211d;
  --muted: #63726c;
  --line: #d6dfd8;
  --paper: #f7f5ee;
  --card: #fffef9;
  --green: #146c4b;
  --lime: #cbec6e;
  --orange: #f36d35;
  --shadow: 0 12px 35px rgba(26, 46, 36, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 5% 3%, rgba(203, 236, 110, 0.36), transparent 26rem),
    radial-gradient(circle at 95% 12%, rgba(243, 109, 53, 0.16), transparent 25rem),
    var(--paper);
  font-family: "Space Grotesk", sans-serif;
}

button, input { font: inherit; }
button { cursor: pointer; }

main { width: min(1440px, calc(100% - 40px)); margin: 0 auto; padding: 26px 0 64px; }

.topbar, .intro, .toolbar, .section-heading, .pagination { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.topbar { border-bottom: 1px solid var(--line); padding-bottom: 22px; }
.eyebrow { margin: 0 0 6px; color: var(--green); font: 500 0.73rem "DM Mono", monospace; letter-spacing: 0.1em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.45rem, 2.5vw, 2rem); letter-spacing: -0.07em; }
h1 span { color: var(--green); }
h2 { margin: 0; font-size: clamp(1.85rem, 4vw, 3.6rem); line-height: 0.96; letter-spacing: -0.075em; }
.connection-status { margin: 0; color: var(--muted); font: 0.78rem "DM Mono", monospace; }
.connection-status.ok { color: var(--green); }
.connection-status.error { color: #a3291d; }

.intro { padding: clamp(38px, 7vw, 86px) 0 28px; align-items: end; }
.intro > p { max-width: 410px; margin: 0; color: var(--muted); line-height: 1.55; }

.summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin: 22px 0 40px; }
.metric { min-height: 120px; padding: 18px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.metric:nth-child(2n) { background: var(--lime); }
.metric strong { display: block; margin-top: 13px; font-size: clamp(1.5rem, 2.5vw, 2.25rem); letter-spacing: -0.06em; }
.metric span { color: var(--muted); font: 0.7rem "DM Mono", monospace; text-transform: uppercase; }

.workspace, .regions-section { padding: 22px; background: rgba(255, 254, 249, 0.76); border: 1px solid var(--line); box-shadow: var(--shadow); }
.source-toggle { display: flex; gap: 5px; padding: 4px; background: #e8ede7; border-radius: 999px; }
.toggle, .filters button, .quiet { border: 0; border-radius: 999px; padding: 9px 13px; color: var(--ink); background: transparent; font-size: 0.83rem; font-weight: 600; }
.toggle.active { color: #fff; background: var(--green); }
.filters { display: flex; flex-wrap: wrap; justify-content: end; gap: 7px; }
.filters input { width: 115px; padding: 8px 10px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 4px; font-size: 0.8rem; }
.filters button[type="submit"] { color: #fff; background: var(--green); border-radius: 4px; }
.quiet { border: 1px solid var(--line); background: #fff; }
.listing-status, #regions-status { margin: 21px 0 12px; color: var(--muted); font: 0.76rem "DM Mono", monospace; }

.listings { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.listing-card { overflow: hidden; display: flex; flex-direction: column; min-height: 355px; background: var(--card); border: 1px solid var(--line); }
.listing-card img { width: 100%; height: 154px; object-fit: cover; background: #e8ede7; }
.listing-card > div { display: flex; flex: 1; flex-direction: column; padding: 14px; }
.listing-card h3 { margin: 7px 0 8px; font-size: 1rem; line-height: 1.12; letter-spacing: -0.035em; }
.listing-meta { color: var(--muted); font: 0.75rem "DM Mono", monospace; line-height: 1.5; }
.tag { display: inline-block; width: fit-content; padding: 4px 7px; color: var(--green); background: #e8f3e7; font: 0.67rem "DM Mono", monospace; }
.card-actions { display: flex; gap: 7px; margin-top: auto; padding-top: 13px; }
.card-actions button { padding: 7px 9px; border: 0; color: var(--green); background: none; font-size: 0.75rem; font-weight: 700; }
.card-actions button:first-child { color: #fff; background: var(--green); }
.empty { grid-column: 1 / -1; padding: 30px; color: var(--muted); text-align: center; }
.pagination { justify-content: center; margin-top: 22px; }
#page-label { min-width: 82px; text-align: center; font: 0.75rem "DM Mono", monospace; }

.regions-section { margin-top: 22px; }
.region-table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { padding: 11px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font: 0.68rem "DM Mono", monospace; text-transform: uppercase; }

dialog { width: min(940px, calc(100% - 28px)); max-height: 86vh; padding: 30px; color: var(--ink); background: var(--card); border: 1px solid var(--line); box-shadow: 0 20px 80px rgba(0, 0, 0, 0.25); }
dialog::backdrop { background: rgba(22, 33, 29, 0.56); backdrop-filter: blur(3px); }
.close-button { position: absolute; top: 10px; right: 13px; border: 0; background: none; font-size: 1.8rem; }
.detail-header { padding-right: 35px; }
.detail-header h2 { margin: 8px 0 16px; font-size: 2rem; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.detail-image { width: 100%; max-height: 340px; object-fit: contain; background: #ecf0ec; }
.detail-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.detail-images img { width: 100%; height: 110px; object-fit: cover; }
.data-list { margin: 0; padding: 0; list-style: none; }
.data-list li { padding: 9px 0; border-bottom: 1px solid var(--line); }
.data-list span { display: block; color: var(--muted); font: 0.67rem "DM Mono", monospace; text-transform: uppercase; }
.seller-photos { display: flex; flex-wrap: wrap; gap: 8px; }
.seller-photos img { width: 98px; height: 98px; object-fit: cover; }

@media (max-width: 850px) {
  main { width: min(100% - 24px, 1440px); }
  .summary { grid-template-columns: repeat(2, 1fr); }
  .intro, .toolbar { align-items: stretch; flex-direction: column; }
  .filters { justify-content: start; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .topbar { align-items: start; flex-direction: column; }
  .summary { grid-template-columns: 1fr; }
  .filters input { width: calc(50% - 4px); }
  dialog { padding: 22px 16px; }
}
