* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  background: #f3f4f6;
  color: #1f2933;
}

header {
  background: #ffffff;
  color: inherit;
  padding: 2.5rem 1.5rem 2rem;
  border-bottom: 1px solid #e2e8f0;
  text-align: center;
}

header h1 {
  margin: 0;
  font-size: 2.25rem;
  font-weight: 700;
  color: #0f172a;
}

header p {
  margin: 0.75rem auto 0;
  max-width: 640px;
  line-height: 1.5;
  font-size: 1.05rem;
  color: #475569;
}

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

.card {
  background: white;
  border-radius: 18px;
  box-shadow: 0 24px 48px -32px rgba(15, 23, 42, 0.45);
  padding: 2rem;
  margin-bottom: 2rem;
}

.card h2 {
  margin-top: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: #1e3a8a;
}

.alert {
  background: #f1f5f9;
  border-radius: 14px;
  padding: 1rem;
  border: 1px solid rgba(30, 64, 175, 0.2);
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.alert strong {
  color: #1e3a8a;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.primary-controls .control {
  min-width: 220px;
}

.secondary-controls {
  align-items: flex-end;
}

.selected-states {
  /* Compact chip row that can live in the actions column */
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.25rem;
  min-height: 1.1rem;
}

.selected-state-chip {
  /* Ultra-compact “[AK ×]” chip */
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
  padding: 0.08rem 0.25rem;
  border-radius: 999px;
  font-size: 0.68rem;
  line-height: 1;
  background: #eef2ff;
  color: #1e3a8a;
  border: 1px solid rgba(30, 64, 175, 0.35);
  cursor: pointer;
  vertical-align: middle;
}

/* removed decorative brackets for compact chips */
.selected-state-chip::before,
.selected-state-chip::after {
  content: none;
}

.selected-state-chip button {
  /* Make the × smaller and vertically centered */
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 0.55rem;
  line-height: 1;
  padding: 0;
  margin: 0;
  transform: translateY(-0.5px);
}

.selected-state-chip button:hover {
  color: #0f172a;
}

.control.actions {
  /* Stack chips above button and keep the button at the bottom */
  flex: 0 0 220px;
  justify-content: flex-end;
  align-items: stretch;
  gap: 0.5rem;
}

.control.actions .selected-states {
  /* Ensure chips appear above the button and wrap nicely */
  margin-bottom: 0.25rem;
}

.selected-state-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  background: #e0e7ff;
  color: #1e3a8a;
  border: 1px solid rgba(30, 64, 175, 0.35);
}

.selected-state-chip button {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0;
}

.selected-state-chip button:hover {
  color: #0f172a;
}

.control {
  flex: 1 1 220px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.control.wide {
  flex: 2 1 360px;
}

.control.actions {
  flex: 0 0 180px;
  justify-content: flex-end;
}

.control label {
  font-weight: 600;
  color: #334155;
}

.control small {
  font-size: 0.8rem;
  color: #64748b;
}

.control input,
.control select {
  border: 1px solid #d0d7e2;
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  background: #f8fafc;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.control input:focus,
.control select:focus {
  outline: none;
  border-color: #2563eb;
  background: white;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.control > button {
  border: none;
  border-radius: 10px;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: white;
  background: #1d4ed8;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.control > button:hover {
  background: #1e40af;
  box-shadow: 0 10px 20px -12px rgba(29, 78, 216, 0.7);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: #475569;
}

.checkbox input {
  width: auto;
  height: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  border-radius: 14px;
  overflow: hidden;
}

thead {
  background: #1e3a8a;
  color: white;
}

th,
td {
  padding: 0.85rem 1rem;
  text-align: left;
  font-size: 0.96rem;
}

tbody tr:nth-child(odd) {
  background: #f8fafc;
}

tbody tr:hover {
  background: #e2e8f04f;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge.yes {
  background: #dcfce7;
  color: #166534;
}

.badge.no {
  background: #fee2e2;
  color: #b91c1c;
}

.dataset-info {
  margin-top: 1.5rem;
  padding: 1rem;
  background: #f1f5f9;
  border-radius: 14px;
  border: 1px solid rgba(30, 64, 175, 0.12);
}

.dataset-info a {
  color: #2563eb;
  text-decoration: none;
}

.dataset-info a:hover {
  text-decoration: underline;
}

.status {
  display: none;
  margin: 1.5rem 0 0.5rem;
  padding: 0.9rem 1.1rem;
  border-radius: 12px;
  background: #eef2ff;
  color: #1e3a8a;
  border: 1px solid rgba(79, 70, 229, 0.25);
}

.status.show {
  display: block;
}

.status.error {
  background: #fee2e2;
  color: #b91c1c;
  border-color: rgba(185, 28, 28, 0.35);
}

.status.warning {
  background: #fef3c7;
  color: #92400e;
  border-color: rgba(217, 119, 6, 0.35);
}

footer {
  margin-top: 2.5rem;
  text-align: center;
  color: #475569;
  font-size: 0.9rem;
}

@media (max-width: 720px) {
  header h1 {
    font-size: 1.9rem;
  }

  header p {
    font-size: 0.95rem;
  }

  .card {
    padding: 1.5rem;
  }

  th,
  td {
    font-size: 0.9rem;
  }
}

.table-wrapper {
  overflow-x: auto;
  border-radius: 14px;
}
