/* ── Tokens (shared with geo-check) ── */
:root {
  --swiss-red: #d8232a;
  --federal-blue: #1a365d;
  --federal-blue-light: #2d4a7a;
  --federal-blue-hover: rgba(26, 54, 93, 0.04);
  --federal-blue-ring: rgba(26, 54, 93, 0.2);

  --color-white: #fff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  --font-family: "Source Sans 3", "Source Sans Pro", system-ui, -apple-system, sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", "Consolas", monospace;

  --radius-sm: 4px;
  --radius-md: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);

  --z-dropdown: 100;

  --header-height: 56px;
  --footer-height: 36px;
}

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

body {
  font-family: var(--font-family);
  font-size: 15px;
  line-height: 1.5;
  color: var(--gray-800);
  background: var(--gray-50);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.header {
  height: var(--header-height);
  background: var(--color-white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  flex-shrink: 0;
}

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

.header-flag { flex-shrink: 0; }

.header-title {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.header-agency {
  font-size: 0.75rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.header-app {
  font-size: 1rem;
  font-weight: 600;
  color: var(--federal-blue);
}

.lang-select {
  font-family: var(--font-family);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--color-white);
  color: var(--gray-700);
  cursor: pointer;
}

/* ── Main ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  gap: 1.5rem;
}

/* ── Search Panel ── */
.search-panel {
  background: var(--color-white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.search-heading {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--federal-blue);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--swiss-red);
}

.search-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-group label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-600);
}

.form-group input,
.form-group select {
  font-family: var(--font-family);
  font-size: 0.9375rem;
  height: 36px;
  padding: 0 0.625rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--color-white);
  color: var(--gray-800);
  transition: border-color 150ms, box-shadow 150ms;
}

.form-group input::placeholder {
  color: var(--gray-400);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--federal-blue);
  box-shadow: 0 0 0 2px var(--federal-blue-ring);
}

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

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: var(--z-dropdown);
  margin: 2px 0 0;
  padding: 0.25rem 0;
  list-style: none;
  background: var(--color-white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 220px;
  overflow-y: auto;
}

.autocomplete-list li {
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
  color: var(--gray-700);
  cursor: pointer;
  transition: background 100ms;
}

.autocomplete-list li:hover,
.autocomplete-list li.active {
  background: var(--federal-blue-hover);
}

.autocomplete-list li b {
  font-weight: 600;
  color: var(--gray-900);
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.75rem;
  padding-top: 0.5rem;
}

/* ── Buttons ── */
.btn {
  font-family: var(--font-family);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.5rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 150ms, border-color 150ms, color 150ms;
  white-space: nowrap;
}

.btn-primary {
  background: var(--federal-blue);
  color: var(--color-white);
}
.btn-primary:hover { background: var(--federal-blue-light); }

.btn-secondary {
  background: var(--color-white);
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); }

.btn-ghost {
  background: transparent;
  color: var(--federal-blue);
  padding: 0.375rem 0.75rem;
}
.btn-ghost:hover { background: var(--federal-blue-hover); }

.btn-sm { font-size: 0.8125rem; padding: 0.3rem 0.75rem; }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Loading state ── */
.btn-primary.loading {
  pointer-events: none;
  opacity: 0.7;
}
.btn-primary.loading::after {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 0.5rem;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Results Panel ── */
.results-panel {
  background: var(--color-white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.results-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
}

.results-heading {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
}

.results-count {
  font-size: 0.8125rem;
  color: var(--gray-500);
}

.results-table-wrap { overflow-x: auto; }

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.results-table th {
  text-align: left;
  font-weight: 600;
  color: var(--gray-600);
  background: var(--gray-50);
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.results-table td {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

.results-table tbody tr {
  cursor: pointer;
  transition: background 100ms;
}
.results-table tbody tr:hover { background: var(--federal-blue-hover); }
.results-table tbody tr:focus-visible {
  outline: 2px solid var(--federal-blue);
  outline-offset: -2px;
}
.results-table tbody tr.selected { background: rgba(26, 54, 93, 0.06); }

.results-table .egrid-cell {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.status-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  white-space: nowrap;
}
.status-badge.active {
  background: #f0fdf4;
  color: #15803d;
}
.status-badge.inactive {
  background: #fef2f2;
  color: #dc2626;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--gray-200);
}

.page-info {
  font-size: 0.8125rem;
  color: var(--gray-500);
}

/* ── Detail Panel ── */
.detail-panel {
  background: var(--color-white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
}

.detail-heading {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
}

.detail-body {
  padding: 1.25rem 1.5rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 2rem;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.detail-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.detail-value {
  font-size: 0.9375rem;
  color: var(--gray-800);
}

.detail-value.mono {
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.detail-links {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-100);
  flex-wrap: wrap;
}

.detail-link {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--federal-blue);
  text-decoration: none;
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  transition: background 150ms;
}
.detail-link:hover { background: var(--federal-blue-hover); }

.detail-value.area {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ── Empty / Error states ── */
.message-box {
  padding: 2rem;
  text-align: center;
  color: var(--gray-500);
  font-size: 0.9375rem;
}

.error-box {
  padding: 1rem 1.5rem;
  background: #fef2f2;
  color: #dc2626;
  font-size: 0.875rem;
  border-bottom: 1px solid #fecaca;
}

/* ── Footer ── */
.footer {
  height: var(--footer-height);
  border-top: 1px solid var(--gray-200);
  background: var(--color-white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  font-size: 0.75rem;
  color: var(--gray-400);
  flex-shrink: 0;
}

.footer-info {
  display: flex;
  gap: 0.375rem;
}

.footer-links {
  display: flex;
  gap: 1rem;
}

.footer a {
  color: var(--gray-500);
  text-decoration: none;
}
.footer a:hover { text-decoration: underline; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .search-form {
    grid-template-columns: 1fr;
  }
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .main { padding: 1rem; }
}
