:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --surface: #ffffff;
  --ink: #17211d;
  --muted: #68736e;
  --line: #dbe3de;
  --accent: #0b6b55;
  --accent-2: #b33f1f;
  --soft: #e9f3ee;
  --shadow: 0 18px 50px rgba(23, 33, 29, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(11, 107, 85, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(179, 63, 31, 0.10), transparent 38%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 0 18px;
}

h1 {
  margin: 0;
  font-size: 40px;
  line-height: 1;
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
}

.topbar .market-note {
  margin-top: 4px;
  color: #48544f;
  font-weight: 700;
}

.browser-note {
  max-width: 680px;
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 700;
}

.status {
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: right;
}

.status[hidden] {
  display: none;
}

.status.error-status {
  color: var(--accent-2);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0 16px;
}

.tab,
button[type="submit"] {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

main {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
}

#suggest-form {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

#rank-form {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 8px 10px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 107, 85, 0.14);
}

button[type="submit"] {
  align-self: end;
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  font-weight: 800;
}

button.secondary {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  font-weight: 800;
}

.compare-form {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.compare-actions {
  display: flex;
  justify-content: flex-end;
}

.autocomplete {
  position: relative;
}

.autocomplete-menu {
  display: none;
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.autocomplete-menu.open {
  display: grid;
}

.autocomplete-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 46px;
  padding: 9px 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: white;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.autocomplete-option:last-child {
  border-bottom: 0;
}

.autocomplete-option:hover,
.autocomplete-option:focus {
  background: var(--soft);
}

.autocomplete-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.autocomplete-option strong {
  color: var(--accent);
  font-size: 12px;
}

.autocomplete-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  text-transform: none;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

.results {
  min-height: 420px;
  padding: 16px;
  overflow: auto;
}

.summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

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

th {
  background: var(--soft);
  color: #33413b;
  font-size: 12px;
  text-transform: uppercase;
}

.sort-header {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: inherit;
  text-align: inherit;
  text-transform: inherit;
}

.sort-header:hover,
.sort-header:focus {
  color: var(--accent);
}

td.num,
th.num {
  text-align: right;
}

tr:hover td {
  background: #fbfdfc;
}

.comparison {
  display: grid;
  gap: 12px;
}

.comparison-cards {
  display: none;
}

.empty,
.error {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.error {
  border-color: rgba(179, 63, 31, 0.32);
  color: var(--accent-2);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--accent);
  font-weight: 800;
}

@media (max-width: 900px) {
  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #suggest-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #rank-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 560px) {
  .app {
    width: min(100% - 16px, 1180px);
    padding-top: 10px;
  }

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

  h1 {
    font-size: 34px;
  }

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

  #suggest-form {
    grid-template-columns: 1fr;
  }

  #rank-form {
    grid-template-columns: 1fr;
  }

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

  .compare-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .autocomplete-menu {
    max-height: 240px;
  }

  .autocomplete-option {
    grid-template-columns: 1fr;
    gap: 3px;
    min-height: 54px;
  }

  th,
  td {
    padding: 9px 10px;
  }

  #compare-results {
    overflow: visible;
  }

  .comparison-table {
    display: none;
  }

  .comparison-cards {
    display: grid;
    gap: 12px;
  }

  .comparison-card {
    display: grid;
    gap: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    overflow: hidden;
  }

  .comparison-card h3 {
    margin: 0;
    padding: 12px;
    background: var(--soft);
    color: var(--ink);
    font-size: 16px;
    line-height: 1.25;
  }

  .comparison-row {
    display: grid;
    grid-template-columns: minmax(95px, 0.8fr) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 10px 12px;
    border-top: 1px solid var(--line);
  }

  .comparison-row span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .comparison-row strong {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 14px;
    text-align: right;
  }

}
