:root {
  color-scheme: light;
  --bg: #f7f8f8;
  --panel: #ffffff;
  --panel-border: #d9e0e3;
  --ink: #182024;
  --muted: #5c6a70;
  --soft: #e9eef0;
  --accent: #0f766e;
  --accent-dark: #0b5d57;
  --good: #15803d;
  --bad: #b91c1c;
  --warn: #b45309;
  --unknown: #69737a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 0 14px;
}

.topbar-titles {
  flex: 1;
  min-width: 0;
}

.topbar-actions {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.action-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: 200px;
  min-width: 0;
  max-width: 200px;
}

.action-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
  min-width: 0;
}

.action-meta #statusText,
.action-meta #ratePill {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-meta #ratePill {
  font-weight: 700;
  color: var(--ink);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.9rem, 3.5vw, 3.35rem);
  line-height: 1.03;
  letter-spacing: 0;
}

h2 {
  font-size: 1rem;
  letter-spacing: 0;
}

.refresh-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid #0b5d5733;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

.refresh-button.secondary {
  border-color: #cbd5d9;
  background: #ffffff;
  color: var(--accent-dark);
}

.refresh-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.summary-card,
.map-panel,
.table-panel,
.details {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel);
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--unknown);
}

.status-dot.loading {
  background: var(--warn);
}

.status-dot.ready {
  background: var(--good);
}

.status-dot.error {
  background: var(--bad);
}

.product-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 8px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: var(--panel);
  overflow-x: auto;
  scrollbar-width: thin;
}

.product-divider {
  flex: 0 0 auto;
  width: 1px;
  height: 22px;
  background: var(--panel-border);
}

.control-group {
  min-width: 0;
}

.compare-controls {
  display: flex;
  align-items: end;
  gap: 18px;
  margin-bottom: 12px;
}

.base-control {
  width: min(360px, 100%);
}

.control-label,
.controls label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.category-tabs,
.product-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.product-tabs {
  flex: 1 1 auto;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab-button,
.product-button {
  flex: 0 0 auto;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.tab-button {
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.product-button {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.product-button span {
  display: none;
}

.tab-button:hover,
.product-button:hover {
  background: var(--soft);
}

.tab-button.selected,
.product-button.selected {
  border-color: var(--accent);
  background: #e4f4ef;
  color: #073f3b;
}

select {
  min-height: 38px;
  width: 100%;
  border: 1px solid #cbd5d9;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  margin-bottom: 0;
  white-space: nowrap;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

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

.summary-card {
  min-height: 92px;
  padding: 12px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.summary-card strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.02rem, 1.4vw, 1.28rem);
  line-height: 1.1;
}

.summary-card p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(420px, 1.1fr) minmax(460px, 0.9fr);
  gap: 16px;
  margin-top: 16px;
}

.map-panel,
.table-panel {
  min-height: 640px;
  padding: 14px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading span {
  color: var(--muted);
  font-size: 0.88rem;
}

.map-wrap {
  position: relative;
  width: 100%;
  min-height: 500px;
  overflow: hidden;
  border-radius: 8px;
  background: #eef3f1;
}

#priceMap {
  width: 100%;
  height: 500px;
}

.leaflet-container {
  background: #eef3f1;
  font: inherit;
}

.leaflet-tooltip {
  border: 0;
  border-radius: 8px;
  box-shadow: 0 10px 26px #1118272b;
  color: var(--ink);
  line-height: 1.35;
}

.country-map-tooltip {
  background: #ffffff;
  color: #182024;
  font-size: 0.82rem;
  font-weight: 750;
  padding: 9px 12px;
  border-radius: 12px;
}

.country-map-tooltip::before {
  display: none !important;
}

.table-wrap {
  overflow: visible;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--soft);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fbfb;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

td {
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

th:nth-child(1),
td:nth-child(1) {
  width: 30%;
}

th:nth-child(2),
td:nth-child(2) {
  width: 24%;
}

th:nth-child(3),
td:nth-child(3) {
  width: 22%;
}

th:nth-child(4),
td:nth-child(4) {
  width: 24%;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.country-cell {
  min-width: 0;
}

.country-link {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: underline;
  text-decoration-color: #0f766e33;
  text-underline-offset: 3px;
}

.country-link:hover {
  text-decoration-color: #0f766e;
}

.delta {
  font-weight: 800;
}

.delta.good {
  color: var(--good);
}

.delta.bad {
  color: var(--bad);
}

.delta.neutral {
  color: var(--muted);
}

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

.details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 14px;
  padding: 12px 14px;
}

.details h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.details p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

@media (max-width: 1050px) {
  .workspace,
  .details {
    grid-template-columns: 1fr;
  }

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

  .compare-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .base-control {
    width: 100%;
  }

  .toggle {
    align-self: start;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 16px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

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

  .map-panel,
  .table-panel {
    min-height: auto;
  }

  #priceMap,
  .map-wrap {
    min-height: 360px;
    height: 360px;
  }
}
