*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #f5f5f5;
  color: #222;
  min-height: 100vh;
}

.app { max-width: 1400px; margin: 0 auto; padding: 1.5rem; }

header { margin-bottom: 1.5rem; }
header h1 { font-size: 1.8rem; font-weight: 700; color: #e2511a; }
header .subtitle { color: #666; margin-top: 0.25rem; }
.scrape-info { font-size: 0.8rem; color: #999; margin-top: 0.4rem; }

/* Filters */
.filters {
  display: flex; flex-wrap: wrap; gap: 0.75rem;
  background: #fff; padding: 1rem 1.25rem; border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 1rem;
  align-items: flex-end;
}
.filter-group { display: flex; flex-direction: column; gap: 0.25rem; min-width: 160px; position: relative; }
.filter-group--person { min-width: 200px; }
.filter-group--search { flex: 1; min-width: 220px; }
.filter-group label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; color: #666; }
.filter-group input {
  padding: 0.45rem 0.65rem; border: 1px solid #ddd; border-radius: 5px;
  font-size: 0.9rem; background: #fff; width: 100%;
}
.filter-group input:focus { outline: none; border-color: #3b82f6; }

.btn-secondary {
  padding: 0.45rem 1rem; border: 1px solid #ddd; border-radius: 5px;
  background: #fff; cursor: pointer; font-size: 0.9rem; align-self: flex-end;
}
.btn-secondary:hover { background: #f5f5f5; }

/* Status single-select — match multiselect trigger appearance */
#f-status {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 0.45rem 2rem 0.45rem 0.65rem;
  border: 1px solid #ddd;
  border-radius: 5px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E") no-repeat right 0.65rem center;
  background-size: 8px 5px;
  cursor: pointer;
  font-size: 0.9rem;
  color: #222;
  font-family: inherit;
  line-height: normal;
}
#f-status:focus { outline: none; border-color: #3b82f6; }

/* Multi-select dropdown */
.multiselect { position: relative; width: 100%; }

.multiselect__trigger {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 0.45rem 0.65rem;
  border: 1px solid #ddd; border-radius: 5px;
  background: #fff; cursor: pointer;
  font-size: 0.9rem; color: #222;
  text-align: left; gap: 0.5rem;
}
.multiselect__trigger:focus { outline: none; border-color: #3b82f6; }
.multiselect__trigger.is-active { border-color: #3b82f6; }

.multiselect__label {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.multiselect__label.has-selection { font-weight: 500; }

.multiselect__arrow { font-size: 0.75rem; color: #888; flex-shrink: 0; transition: transform 0.15s; }
.multiselect__trigger.is-active .multiselect__arrow { transform: rotate(180deg); }

.multiselect__panel {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  z-index: 300;
  max-height: 240px;
  overflow-y: auto;
  padding: 0.25rem 0;
}
.multiselect__panel.is-open { display: block; }

.multiselect__option {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  font-size: 0.88rem;
  color: #333;
  user-select: none;
  border-bottom: 1px solid #f5f5f5;
}
.multiselect__option:last-child { border-bottom: none; }
.multiselect__option:hover { background: #fef3ee; }

.multiselect__option input[type="checkbox"] {
  accent-color: #e2511a;
  width: 14px; height: 14px; flex-shrink: 0;
  cursor: pointer;
  margin: 0; padding: 0; border: none;
}

.multiselect__option.is-checked { color: #e2511a; font-weight: 500; }

/* Person autocomplete */
.autocomplete-wrap { position: relative; }

.suggestions {
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  margin: 0; padding: 0;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  display: none;
}
.suggestions.open { display: block; }
.suggestions li {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.88rem;
  color: #333;
  border-bottom: 1px solid #f0f0f0;
}
.suggestions li:last-child { border-bottom: none; }
.suggestions li:hover,
.suggestions li.active { background: #fef3ee; color: #e2511a; }

/* Results bar */
.results-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.75rem; font-size: 0.9rem; color: #555;
}
.pagination { display: flex; gap: 0.5rem; }
.pagination button {
  padding: 0.3rem 0.65rem; border: 1px solid #ddd; border-radius: 4px;
  background: #fff; cursor: pointer; font-size: 0.85rem;
}
.pagination button.active { background: #e2511a; color: #fff; border-color: #e2511a; }
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* Badge cards grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.card {
  background: #fff; border-radius: 8px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  display: flex; flex-direction: column;
  transition: transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.12); }

.card__image {
  background: #f9f9f9; display: flex; align-items: center; justify-content: center;
  height: 140px; padding: 1rem;
}
.card__image img { max-height: 100%; max-width: 100%; object-fit: contain; }
.card__image .no-img { color: #ccc; font-size: 2.5rem; }

.card__body { padding: 0.85rem 1rem; flex: 1; display: flex; flex-direction: column; gap: 0.3rem; }
.card__name { font-weight: 600; font-size: 0.9rem; line-height: 1.3; }
.card__issuer { font-size: 0.8rem; color: #e2511a; font-weight: 500; }
.card__person { font-size: 0.8rem; color: #666; }
.card__meta { font-size: 0.75rem; color: #999; margin-top: auto; padding-top: 0.5rem; }

.badge-status {
  display: inline-block; padding: 0.15rem 0.45rem; border-radius: 3px;
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase; margin-bottom: 0.3rem;
}
.badge-status--active  { background: #d4edda; color: #155724; }
.badge-status--expired { background: #f8d7da; color: #721c24; }
.badge-status--soon    { background: #fff3cd; color: #856404; }
.badge-status--noexpiry{ background: #e8e8e8; color: #555; }

.loading { text-align: center; padding: 3rem; color: #999; font-size: 1rem; }
.error { background: #f8d7da; color: #721c24; padding: 1rem; border-radius: 6px; margin-top: 1rem; }

.card__link {
  display: inline-block; margin-top: 0.5rem; font-size: 0.78rem;
  color: #e2511a; text-decoration: none;
}
.card__link:hover { text-decoration: underline; }

/* Footer */
.footer {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  margin-top: 2rem;
  padding: 1rem 0 0.5rem;
  border-top: 1px solid #e5e5e5;
  font-size: 0.8rem;
  color: #999;
}
.footer a {
  color: #e2511a;
  text-decoration: none;
}
.footer a:hover { text-decoration: underline; }

@media (max-width: 600px) {
  .filters { flex-direction: column; }
  .filter-group { min-width: 100%; }
}
