/* =============================================================================
   Design Tokens
   ============================================================================= */
:root {
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --surface-tinted: #FBFCFE;
  --border: #DDE5ED;
  --border-strong: #B9C6D3;
  --text-primary: #13202F;
  --text-secondary: #31445A;
  --text-muted: #64758A;
  --accent: #1264A3;
  --accent-hover: #0B4E7F;
  --accent-soft: #E8F3FF;
  --civic-ink: #143642;
  --civic-teal: #2A9D8F;
  --permit-amber: #F59E0B;
  --registry-green: #11845B;
  --case-indigo: #4F46E5;
  --notice-rose: #E11D48;
  --success: #11845B;
  --warning: #B45309;
  --error: #EF4444;
  --error-bg: #FEF2F2;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, Consolas, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --header-height: 64px;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(20, 54, 66, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(20, 54, 66, 0.03) 1px, transparent 1px),
    linear-gradient(135deg, #F5F7FA 0%, #EEF7F4 48%, #FFF8EA 100%);
  background-size: 32px 32px, 32px 32px, auto;
  color: var(--text-primary);
  font-family: var(--font-family);
  line-height: 1.5;
}

body.modal-open {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.06), transparent 44%),
    linear-gradient(135deg, rgba(20, 54, 66, 0.97), rgba(21, 81, 106, 0.96) 52%, rgba(29, 94, 80, 0.96));
  backdrop-filter: blur(8px);
}

.login-card {
  width: min(92vw, 390px);
  padding: var(--space-8);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-top: 4px solid var(--permit-amber);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #FFFFFF, #F8FBFD);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.36);
}

.login-header {
  margin-bottom: var(--space-6);
  text-align: center;
}

.login-header h1 {
  margin-bottom: var(--space-2);
  color: var(--text-primary);
  font-size: var(--text-xl);
  font-weight: 700;
}

.login-header p,
.login-hint {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.auth-spinner-container {
  display: flex;
  justify-content: center;
  padding: var(--space-6) 0;
}

.login-overlay:not(.auth-loading) .auth-spinner-container,
.login-overlay.auth-loading .login-form,
.login-overlay.auth-loading .login-hint {
  display: none;
}

.auth-spinner,
.button-spinner {
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.auth-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--permit-amber);
  border-right-color: var(--civic-teal);
}

.login-form,
.form-group {
  display: grid;
}

.login-form {
  gap: var(--space-4);
}

.form-group {
  gap: var(--space-1);
}

.form-group label {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 700;
}

.form-group input {
  min-height: 42px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #FFFFFF;
  color: var(--text-primary);
  font-size: var(--text-base);
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(18, 100, 163, 0.14);
}

.login-error {
  padding: var(--space-3);
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  background: var(--error-bg);
  color: var(--error);
  font-size: var(--text-sm);
}

.login-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 42px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--civic-ink);
  color: #FFFFFF;
  font-size: var(--text-base);
  font-weight: 700;
}

.login-button:hover:not(:disabled) {
  background: var(--accent-hover);
}

.login-button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.button-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-top-color: #FFFFFF;
}

.login-hint {
  margin-top: var(--space-4);
  text-align: center;
}

.loading-overlay[hidden],
.app-content[hidden],
[hidden] {
  display: none !important;
}

.loading-card {
  width: min(90vw, 390px);
  padding: var(--space-8);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #FFFFFF, #F8FBFD);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.loading-card.error {
  border: 2px solid var(--error);
}

.loading-card.error .loading-spinner {
  display: none;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-4);
  border: 4px solid var(--border);
  border-top-color: var(--permit-amber);
  border-right-color: var(--civic-teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-card h1 {
  margin-bottom: var(--space-2);
  font-size: var(--text-lg);
  font-weight: 600;
}

.loading-card p {
  color: var(--text-muted);
  font-size: var(--text-sm);
  white-space: pre-line;
}

.retry-btn,
.primary-btn {
  padding: var(--space-2) var(--space-4);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--civic-ink);
  color: white;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background 0.15s ease;
}

.retry-btn {
  margin-top: var(--space-4);
}

.retry-btn:hover,
.primary-btn:hover {
  background: var(--accent-hover);
}

.search-header {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 3px solid var(--permit-amber);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.07), transparent 42%),
    linear-gradient(105deg, var(--civic-ink) 0%, #15516A 52%, #1D5E50 100%);
  color: #FFFFFF;
  box-shadow: 0 12px 32px rgba(19, 32, 47, 0.18);
}

.search-header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  max-width: 1400px;
  height: var(--header-height);
  margin: 0 auto;
  padding: var(--space-3) var(--space-6);
}

.brand {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.lcx-logo {
  flex-shrink: 0;
  border-radius: var(--radius-sm);
}

.brand-text {
  color: #FFFFFF;
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0;
}

.brand-meta {
  color: rgba(255, 255, 255, 0.72);
  font-size: var(--text-xs);
}

.search-container {
  flex: 1;
  max-width: 760px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: var(--space-4);
  color: #6B7C90;
  pointer-events: none;
}

.search-input-wrapper input {
  width: 100%;
  height: 44px;
  padding: 0 calc(var(--space-4) + 64px) 0 calc(var(--space-4) + 28px);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text-primary);
  font-size: var(--text-base);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.search-input-wrapper input:focus {
  outline: none;
  border-color: #9BD3FF;
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(155, 211, 255, 0.35), 0 10px 24px rgba(9, 32, 48, 0.18);
}

.search-input-wrapper input:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.search-input-wrapper input::placeholder {
  color: var(--text-muted);
}

.search-input-wrapper input[type="search"]::-webkit-search-cancel-button,
.search-input-wrapper input[type="search"]::-webkit-search-decoration,
.search-input-wrapper input[type="search"]::-webkit-search-results-button,
.search-input-wrapper input[type="search"]::-webkit-search-results-decoration {
  appearance: none;
}

.keyboard-hint {
  position: absolute;
  right: var(--space-3);
  padding: 2px 6px;
  border: 1px solid #D8E2EC;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  pointer-events: none;
}

.search-clear-btn {
  position: absolute;
  right: calc(var(--space-3) + 34px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
}

.search-clear-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg);
  color: var(--text-primary);
}

.options-toggle,
.clear-all-filters-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.88);
  font-size: var(--text-sm);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.options-toggle:hover,
.clear-all-filters-btn:hover {
  border-color: rgba(255, 255, 255, 0.58);
  background: rgba(255, 255, 255, 0.16);
}

.options-toggle[aria-expanded="true"],
.options-toggle.has-active-filters {
  border-color: rgba(245, 158, 11, 0.92);
  background: rgba(245, 158, 11, 0.16);
  color: #FFFFFF;
}

.user-menu {
  position: relative;
  flex-shrink: 0;
}

.user-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 220px;
  min-height: 38px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  font-size: var(--text-sm);
}

.user-button:hover,
.user-button[aria-expanded="true"] {
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.16);
}

#userEmail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  min-width: 160px;
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #FFFFFF;
  box-shadow: 0 18px 38px rgba(19, 32, 47, 0.18);
}

.user-dropdown button {
  width: 100%;
  min-height: 34px;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  text-align: left;
}

.user-dropdown button:hover {
  background: #FFF1F2;
  color: var(--notice-rose);
}

.filter-active-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--permit-amber);
  color: #1F2937;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.search-options {
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  background: #F8FBFD;
  box-shadow: inset 0 -1px 0 var(--border);
}

.clear-all-filters-btn {
  border-color: var(--border);
  background: #FFFFFF;
  color: var(--text-secondary);
}

.clear-all-filters-btn:hover {
  border-color: var(--notice-rose);
  background: #FFF1F2;
  color: var(--notice-rose);
}

.search-options-inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-6);
}

.filter-controls {
  display: flex;
  flex: 1;
  align-items: end;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.filter-field {
  display: grid;
  gap: var(--space-1);
  min-width: 150px;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.filter-field select,
.filter-field input {
  min-height: 32px;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #FFFFFF, #F8FAFC);
  color: var(--text-primary);
  font-size: var(--text-sm);
}

.filter-field select:focus,
.filter-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(18, 100, 163, 0.12);
}

.date-field {
  min-width: 135px;
}

.limit-field {
  min-width: 92px;
}

.toggle-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 32px;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  user-select: none;
}

.toggle-chip:has(input:checked) {
  border-color: var(--registry-green);
  background: var(--registry-green);
  color: white;
}

.toggle-chip input {
  display: none;
}

.status-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-2) var(--space-6);
  background: var(--error-bg);
  color: var(--error);
  font-size: var(--text-sm);
}

.status-indicator {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-6);
}

.summary-grid {
  display: grid;
  grid-template-columns: 290px repeat(3, minmax(0, 1fr));
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}

.metric-card,
.facet-panel,
.results-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 14px 34px rgba(31, 49, 68, 0.08);
}

.metric-card {
  position: relative;
  min-height: 86px;
  padding: var(--space-4);
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 253, 0.96));
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--metric-color, var(--accent));
}

.summary-grid .metric-card:nth-child(1) {
  --metric-color: var(--accent);
}

.summary-grid .metric-card:nth-child(2) {
  --metric-color: var(--civic-teal);
}

.summary-grid .metric-card:nth-child(3) {
  --metric-color: var(--permit-amber);
}

.summary-grid .metric-card:nth-child(4) {
  --metric-color: var(--case-indigo);
}

.metric-label {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0;
}

.metric-card strong {
  display: block;
  position: relative;
  overflow: hidden;
  color: var(--text-primary);
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-grid {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: var(--space-6);
  align-items: start;
}

.facet-panel {
  position: sticky;
  top: calc(var(--header-height) + var(--space-6));
  overflow: hidden;
  border-top: 4px solid var(--civic-teal);
}

.facet-panel section + section {
  border-top: 1px solid var(--border);
}

.panel-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, #F8FBFD, #FFFFFF);
}

.split-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.panel-header h2 {
  font-size: var(--text-sm);
  font-weight: 600;
}

.panel-count {
  min-width: 22px;
  padding: 1px var(--space-2);
  border-radius: 999px;
  background: #DFF6EF;
  color: var(--registry-green);
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: center;
}

.followup-list {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-2);
}

.followup-empty {
  padding: var(--space-3) var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.followup-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  gap: var(--space-1);
  align-items: start;
  border-radius: var(--radius-sm);
}

.followup-search,
.followup-remove {
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
}

.followup-search {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: var(--space-2);
  color: var(--text-secondary);
  text-align: left;
}

.followup-search:hover {
  background: #FFF7E6;
}

.followup-name,
.followup-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.followup-name {
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 600;
}

.followup-meta {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.followup-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
}

.followup-remove:hover {
  background: var(--error-bg);
  color: var(--error);
}

.facet-list {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-2);
}

.facet-list.compact {
  max-height: 210px;
  overflow: auto;
}

.facet-btn {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: center;
  width: 100%;
  padding: var(--space-2);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  text-align: left;
}

.facet-btn:hover,
.facet-btn.active {
  background: linear-gradient(90deg, var(--accent-soft), #F4FBF8);
  color: var(--accent);
}

.facet-btn.active {
  box-shadow: inset 3px 0 0 var(--permit-amber);
}

.facet-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.facet-count {
  min-width: 28px;
  padding: 1px var(--space-2);
  border-radius: 999px;
  background: #EDF2F7;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.results-section {
  overflow: hidden;
  border-top: 4px solid var(--accent);
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(90deg, #FFFFFF, #F7FBFD);
}

.results-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

#resultCount {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
}

.query-time {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.results-list {
  display: grid;
}

.result-item {
  position: relative;
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.result-item::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--row-color, var(--accent));
}

.result-item:nth-child(5n + 1) {
  --row-color: var(--accent);
}

.result-item:nth-child(5n + 2) {
  --row-color: var(--civic-teal);
}

.result-item:nth-child(5n + 3) {
  --row-color: var(--permit-amber);
}

.result-item:nth-child(5n + 4) {
  --row-color: var(--case-indigo);
}

.result-item:nth-child(5n + 5) {
  --row-color: var(--notice-rose);
}

.result-item:hover {
  background: #FCFEFF;
  box-shadow: inset 0 0 0 999px rgba(18, 100, 163, 0.018);
}

.result-item:last-child {
  border-bottom: none;
}

.result-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.followup-btn {
  flex-shrink: 0;
  min-height: 30px;
  padding: 3px var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #FFFFFF;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 600;
}

.followup-btn:hover {
  border-color: var(--permit-amber);
  background: #FFF7E6;
  color: #8A4B00;
}

.followup-btn.saved {
  border-color: #9FE3C5;
  background: #EAFBF3;
  color: var(--registry-green);
}

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

.result-title {
  color: #0E2738;
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.35;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 100%;
  padding: 3px var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #F7FAFC;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 500;
}

.meta-chip.date-chip {
  border-color: #FCD34D;
  background: linear-gradient(180deg, #FFF8DB, #FFEFC2);
  color: #7C3F00;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.meta-chip.date-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-right: var(--space-1);
  border-radius: 50%;
  background: #F59E0B;
}

.meta-chip.accent {
  border-color: #BFDBFE;
  background: #E8F3FF;
  color: var(--accent);
}

.meta-chip.pdf {
  border-color: #BBF7D0;
  background: #F0FDF4;
  color: #15803D;
  text-decoration: none;
}

.meta-chip.case-link {
  border-color: #C7D2FE;
  background: #F0F1FF;
  color: var(--case-indigo);
  text-decoration: none;
}

.meta-chip.org-link {
  border-color: #FED7AA;
  background: #FFF4E8;
  color: #9A3412;
  text-decoration: none;
}

.meta-chip.org-link:hover {
  border-color: #FDBA74;
  background: #FFEDD5;
}

.meta-chip.brreg-chip {
  border-color: #BAE6FD;
  background: #F0F9FF;
  color: #075985;
}

.pdf-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.pdf-link,
.pdf-missing {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
}

.pdf-link {
  border: 1px solid #A8E7C7;
  background: #EAFBF3;
  color: var(--registry-green);
  text-decoration: none;
}

.pdf-link:hover {
  border-color: #86EFAC;
  background: #DCFCE7;
}

.pdf-missing {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
}

.result-parties {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.party-block {
  min-width: 0;
}

.party-label {
  display: block;
  color: #607086;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0;
}

.party-name {
  overflow-wrap: anywhere;
}

.party-facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.party-facts span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px var(--space-2);
  border: 1px solid #B6DDF6;
  border-radius: var(--radius-sm);
  background: #EDF8FF;
  color: #0B5A87;
  font-size: var(--text-xs);
  font-weight: 600;
}

.party-facts span:nth-child(2) {
  border-color: #A8E7C7;
  background: #EAFBF3;
  color: var(--registry-green);
}

.party-facts span:nth-child(3) {
  border-color: #F8D68A;
  background: #FFF7E6;
  color: #8A4B00;
}

.company-button {
  display: inline;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-hover);
  font-weight: 600;
  text-align: left;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.company-button:hover {
  color: #1E40AF;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: rgba(19, 32, 47, 0.64);
  backdrop-filter: blur(5px);
}

.company-modal {
  width: min(1440px, calc(100vw - 32px));
  height: min(920px, calc(100vh - 32px));
  max-height: calc(100vh - 32px);
  overflow: hidden;
  border: 1px solid rgba(221, 229, 237, 0.92);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 25px 70px rgba(15, 23, 42, 0.28);
}

.company-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  border-bottom: 3px solid var(--permit-amber);
  background: linear-gradient(90deg, var(--civic-ink), #15516A);
  color: #FFFFFF;
}

.company-modal-header h2 {
  font-size: var(--text-xl);
  line-height: 1.25;
}

.company-modal-header p {
  margin-top: var(--space-1);
  color: rgba(255, 255, 255, 0.72);
  font-size: var(--text-sm);
}

.modal-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  color: #FFFFFF;
  font-size: var(--text-xl);
  line-height: 1;
}

.modal-close-btn:hover {
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.16);
}

.company-modal-body {
  display: grid;
  grid-template-columns: minmax(390px, 0.52fr) minmax(680px, 1.48fr);
  gap: 0;
  height: calc(100% - 77px);
  min-height: 0;
  overflow: auto;
}

.company-details {
  min-width: 0;
  overflow: auto;
  padding: var(--space-6);
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, #FFFFFF, #FAFCFE);
}

.company-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.company-action-link,
.company-map-link {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: var(--space-1) var(--space-3);
  border: 1px solid #B6DDF6;
  border-radius: var(--radius-sm);
  background: #E8F3FF;
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 600;
  text-decoration: none;
}

.company-detail-list {
  display: grid;
  gap: var(--space-2);
}

.company-detail-row {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid #E4EBF2;
}

.company-detail-row dt,
.company-text-block span {
  color: #607086;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
  white-space: nowrap;
}

.company-detail-row dd {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-text-block {
  margin-top: var(--space-4);
}

.company-text-block p,
.company-missing {
  margin-top: var(--space-1);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.company-map {
  position: relative;
  min-height: 0;
  background: #DDE5ED;
}

.osm-tile-map {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  background: #E5E7EB;
}

.osm-tile-layer {
  position: absolute;
  inset: 0;
}

.osm-tile-layer img {
  position: absolute;
  width: 256px;
  height: 256px;
  max-width: none;
  user-select: none;
}

.osm-marker-layer {
  position: absolute;
  inset: 0;
}

.osm-marker {
  position: absolute;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 3px solid #FFFFFF;
  border-radius: 50% 50% 50% 0;
  background: #EF4444;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.35);
  transform: translate(-50%, -100%) rotate(-45deg);
}

.osm-marker:hover {
  background: #DC2626;
  z-index: 2;
}

.osm-marker::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #FFFFFF;
}

.osm-attribution {
  position: absolute;
  left: var(--space-2);
  bottom: var(--space-2);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-secondary);
  font-size: 0.68rem;
  text-decoration: none;
}

.osm-attribution:hover {
  text-decoration: underline;
}

.company-map-status {
  position: absolute;
  top: var(--space-4);
  left: var(--space-4);
  right: var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.company-map-link {
  position: absolute;
  right: var(--space-4);
  bottom: var(--space-4);
  border-color: #BBF7D0;
  background: #F0FDF4;
  color: #15803D;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  padding: var(--space-12) var(--space-6);
}

.empty-state-content {
  text-align: center;
}

.empty-state h2 {
  margin-bottom: var(--space-2);
  font-size: var(--text-lg);
}

.empty-state p {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

mark {
  border-radius: 2px;
  background: #FEF3C7;
  color: inherit;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

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

  .facet-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  :root {
    --header-height: auto;
  }

  .search-header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: var(--space-3) var(--space-4);
  }

  .brand {
    width: 100%;
  }

  .search-container {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }

  .options-toggle {
    margin-left: auto;
  }

  .search-options-inner,
  .main-content {
    padding: var(--space-4);
  }

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

  .metric-card strong {
    font-size: var(--text-lg);
  }

  .result-topline,
  .result-parties {
    display: grid;
    grid-template-columns: 1fr;
  }

  .modal-overlay {
    padding: var(--space-3);
  }

  .company-modal {
    width: calc(100vw - 24px);
    height: calc(100vh - 24px);
    max-height: calc(100vh - 24px);
  }

  .company-modal-body {
    grid-template-columns: 1fr;
    height: calc(100% - 89px);
    overflow: auto;
  }

  .company-details {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .company-map,
  .osm-tile-map {
    min-height: 420px;
  }
}

@media (max-width: 520px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .filter-field,
  .filter-controls,
  .toggle-chip,
  .clear-all-filters-btn {
    width: 100%;
  }

  .company-modal-header,
  .company-details {
    padding: var(--space-4);
  }

  .company-detail-row {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }
}
