:root {
  color-scheme: light;
  --bg: #f7f3ec;
  --surface: #ffffff;
  --ink: #111820;
  --muted: #646970;
  --line: #e5e0d8;
  --brand: #111820;
  --brand-2: #2b2e34;
  --accent: #c77a3a;
  --accent-dark: #a85f29;
  --soft: #ede5d8;
  --positive: #317258;
  --danger: #b42318;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.topbar {
  align-items: center;
  background: var(--soft);
  border-bottom: 1px solid #d6ccbe;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  min-height: 68px;
  padding: 10px max(20px, calc((100vw - 1200px) / 2));
}

.brand {
  align-items: center;
  display: flex;
  gap: 18px;
}

.brand-logo {
  display: block;
  height: 42px;
  object-fit: contain;
  width: auto;
}

.brand > span {
  border-left: 1px solid #c7bbaa;
  color: #5e6063;
  font-size: 0.86rem;
  font-weight: 750;
  padding-left: 18px;
}

.source-badge {
  border: 1px solid #b9aa97;
  color: var(--brand);
  font-size: 0.8rem;
  font-weight: 800;
  padding: 7px 10px;
}

.app-shell {
  margin: 0 auto;
  max-width: 1200px;
  padding: 28px 20px 64px;
}

.query-band {
  align-items: end;
  background: var(--surface);
  border-bottom: 3px solid var(--accent);
  display: grid;
  gap: 32px;
  grid-template-columns: minmax(0, 1fr) minmax(480px, 0.9fr);
  padding: 28px;
}

.query-copy {
  max-width: 650px;
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(1.85rem, 4vw, 3.1rem);
  line-height: 1.06;
  margin-bottom: 14px;
  max-width: 720px;
}

h2 {
  font-size: 1.3rem;
  margin-bottom: 0;
}

h2 small {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.query-copy > p:last-child,
.method-note {
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 0;
}

.query-form {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 0.8rem;
  font-weight: 800;
  gap: 6px;
}

input {
  background: #fbfcfc;
  border: 1px solid #bfcdd0;
  border-radius: 4px;
  color: var(--ink);
  min-width: 0;
  padding: 12px;
}

.form-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

button {
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 850;
  min-height: 44px;
  padding: 11px 16px;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

#submit-btn,
.export-button {
  background: var(--accent);
  color: white;
}

#submit-btn:hover,
.export-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  background: white;
  border-color: #b7aaa0;
  color: var(--brand);
}

.status {
  color: var(--muted);
  min-height: 50px;
  padding: 16px 4px;
}

.status.loading {
  color: var(--accent-dark);
  font-weight: 750;
}

.status.success {
  color: var(--positive);
}

.status.error {
  color: var(--danger);
  font-weight: 800;
}

.section-heading {
  align-items: end;
  display: flex;
  justify-content: space-between;
  margin: 18px 0 12px;
}

.section-heading.compact {
  margin-top: 0;
}

.export-button {
  align-items: center;
  display: inline-flex;
  min-height: 40px;
}

.metrics-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card,
.content-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric-card {
  min-height: 132px;
  padding: 18px;
}

.metric-card span,
.metric-card small,
.geometry-item span,
.geometry-item small {
  color: var(--muted);
  display: block;
}

.metric-card span,
.geometry-item span {
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  font-size: 1.85rem;
  margin: 9px 0 3px;
}

.primary-metric {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.primary-metric span,
.primary-metric small {
  color: #d6d8da;
}

.geometry-band {
  background: var(--soft);
  border-left: 4px solid var(--accent);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 14px 0;
}

.geometry-item {
  border-right: 1px solid #d4c9bb;
  min-height: 100px;
  padding: 17px;
}

.geometry-item:last-child {
  border-right: 0;
}

.geometry-item strong {
  display: block;
  font-size: 1.25rem;
  margin: 7px 0 3px;
}

.content-section {
  margin-top: 14px;
  padding: 20px;
}

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

table {
  border-collapse: collapse;
  min-width: 980px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: right;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.3;
  text-transform: uppercase;
}

th:first-child,
td:first-child {
  text-align: left;
}

tbody tr:hover {
  background: #faf7f2;
}

.events-list {
  margin-top: 16px;
}

.event-row {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
}

.event-row:first-child {
  border-top: 0;
}

.event-row strong,
.event-row span {
  display: block;
}

.event-row span {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 3px;
}

.event-row b {
  color: var(--accent-dark);
  text-align: right;
}

@media (max-width: 900px) {
  .query-band {
    grid-template-columns: 1fr;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .geometry-band {
    grid-template-columns: 1fr 1fr;
  }

  .geometry-item:nth-child(2) {
    border-right: 0;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding-inline: 16px;
  }

  .app-shell {
    padding: 16px 12px 40px;
  }

  .query-band,
  .content-section {
    padding: 18px;
  }

  .query-form,
  .form-actions,
  .metrics-grid,
  .geometry-band {
    grid-template-columns: 1fr;
  }

  .geometry-item {
    border-bottom: 1px solid #d4c9bb;
    border-right: 0;
  }

  .geometry-item:last-child {
    border-bottom: 0;
  }

  .section-heading {
    align-items: stretch;
    gap: 12px;
  }

  .export-button {
    flex: 0 0 auto;
  }

  .metric-card {
    min-height: 118px;
  }

  .brand-logo {
    height: 34px;
  }

  .brand > span {
    display: none;
  }
}
