:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #d9dde3;
  --text: #1c2128;
  --text-muted: #5b6472;
  --accent: #2452c9;
  --accent-hover: #1d3fa3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

header {
  padding: 2rem 1.5rem 1rem;
  text-align: center;
}

header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

#search-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: relative;
}

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.badge {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  margin-left: 0.25rem;
}

input, select, button {
  font: inherit;
}

input[type="text"], select {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

input[type="text"]:disabled {
  background: var(--bg);
  color: var(--text-muted);
  cursor: not-allowed;
}

.actions button {
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

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

.suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 10;
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  max-height: 260px;
  overflow-y: auto;
}

.suggestions li {
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.suggestions li:hover,
.suggestions li.active {
  background: var(--bg);
}

.suggestions .sic-code {
  font-weight: 600;
  margin-right: 0.4rem;
}

.status {
  margin-top: 1.5rem;
  color: var(--text-muted);
}

#results-wrap {
  margin-top: 1.5rem;
}

.results-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pagination button {
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.export-link {
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.export-link:hover {
  background: var(--accent);
  color: #fff;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  text-align: left;
  padding: 0.65rem 0.75rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

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

.status-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  background: var(--bg);
  border: 1px solid var(--border);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --surface: #1c1f24;
    --border: #2c3038;
    --text: #e7e9ec;
    --text-muted: #9aa2ad;
    --accent: #5b82e6;
    --accent-hover: #7a9bee;
  }
}

:root[data-theme="dark"] {
  --bg: #14161a;
  --surface: #1c1f24;
  --border: #2c3038;
  --text: #e7e9ec;
  --text-muted: #9aa2ad;
  --accent: #5b82e6;
  --accent-hover: #7a9bee;
}
