/* =============================================================================
   Design Tokens
   ============================================================================= */
:root {
  /* Colors */
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --border-strong: #D1D5DB;
  --text-primary: #0F172A;
  --text-secondary: #334155;
  --text-muted: #64748B;
  --accent: #3B82F6;
  --accent-hover: #2563EB;
  --highlight-bg: #FEF3C7;
  --highlight-border: #F59E0B;
  --error: #EF4444;
  --error-bg: #FEF2F2;
  --radius-lg: 12px;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, Consolas, monospace;
  
  /* Type Scale */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;

  /* Sizing */
  --header-height: 64px;
}

/* =============================================================================
   Reset
   ============================================================================= */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

/* =============================================================================
   Loading Overlay (for static site)
   ============================================================================= */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-overlay[hidden] {
  display: none;
}

.loading-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-8);
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
}

.loading-card.error {
  border: 2px solid var(--error);
}

.loading-card.error .loading-spinner {
  display: none;
}

.loading-card h2 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.loading-card p {
  font-size: var(--text-sm);
  color: var(--text-muted);
  white-space: pre-line;
}

.loading-card .loading-hint {
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.7;
  margin-top: var(--space-3);
}

.retry-btn {
  margin-top: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.retry-btn:hover {
  background: var(--accent-hover);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto var(--space-4);
}

/* Static Badge */
.static-badge {
  display: inline-block;
  padding: 2px 6px;
  background: #10B981;
  color: white;
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-sm);
  margin-left: var(--space-2);
}

/* =============================================================================
   App Content — Hidden until initialized
   ============================================================================= */
.app-content[hidden] {
  display: none !important;
}

/* =============================================================================
   Search Header — The Dominant Element
   ============================================================================= */
.search-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.search-header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-6);
  height: var(--header-height);
}

/* Brand — Minimal, doesn't compete with search */
.brand {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.brand:hover {
  opacity: 0.8;
}

.lcx-logo {
  flex-shrink: 0;
  border-radius: var(--radius-sm);
}

.brand-text {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.brand-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Search Container — Takes maximum space */
.search-container {
  flex: 1;
  max-width: 720px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: var(--space-4);
  color: var(--text-muted);
  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 var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input-wrapper input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  background: var(--surface);
}

.search-input-wrapper input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.search-input-wrapper input::placeholder {
  color: var(--text-muted);
}

/* Hide native search clear button to avoid double X */
.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 {
  -webkit-appearance: none;
  appearance: none;
}

.search-input-wrapper input[type="search"]::-ms-clear,
.search-input-wrapper input[type="search"]::-ms-reveal {
  display: none;
  width: 0;
  height: 0;
}

.keyboard-hint {
  position: absolute;
  right: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-clear-btn {
  position: absolute;
  right: calc(var(--space-3) + 34px);
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.search-clear-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--bg);
}

.search-clear-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  border-color: var(--accent);
}

.search-clear-btn[hidden] {
  display: none;
}

/* Options Toggle Button */
.options-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}

.options-toggle:hover {
  background: var(--bg);
  border-color: var(--border-strong);
}

.options-toggle[aria-expanded="true"] {
  background: var(--bg);
  border-color: var(--accent);
  color: var(--accent);
}

/* Filter Active Badge */
.filter-active-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--accent);
  color: white;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.filter-active-badge[hidden] {
  display: none;
}

/* Highlight the filter button when filters are active */
.options-toggle.has-active-filters {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.05);
}

/* =============================================================================
   Search Options — Hidden by default
   ============================================================================= */
.search-options {
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.search-options[hidden] {
  display: none;
}

.search-options-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-6);
}

.field-toggles {
  display: flex;
  gap: var(--space-2);
}

.toggle-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, background 0.15s;
}

.toggle-chip:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.toggle-chip input {
  display: none;
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.platform-selector,
.kommune-selector,
.fylke-selector,
.limit-selector {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.platform-selector label,
.kommune-selector label,
.fylke-selector label,
.limit-selector label {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.platform-selector select,
.kommune-selector select,
.fylke-selector select,
.limit-selector select {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: inherit;
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  min-width: 120px;
}

.platform-selector select,
.kommune-selector select,
.fylke-selector select {
  min-width: 180px;
}

/* =============================================================================
   Searchable Dropdown Components
   ============================================================================= */
.searchable-dropdown {
  position: relative;
  flex-shrink: 0;
}

.platform-selector.searchable-dropdown,
.kommune-selector.searchable-dropdown,
.fylke-selector.searchable-dropdown {
  min-width: 180px;
  width: 180px;
}

.searchable-dropdown input[type="text"] {
  width: 100%;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: inherit;
  background: var(--surface);
  color: var(--text-primary);
  cursor: text;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.searchable-dropdown input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.searchable-dropdown input[type="text"]::placeholder {
  color: var(--text-muted);
}

.searchable-dropdown input[type="text"][data-selected] {
  font-weight: 500;
}

.searchable-dropdown-list {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  max-height: 300px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  z-index: 200;
  overscroll-behavior: contain;
  width: max-content;
  min-width: 100%;
}

/* Scrollbar styling for webkit browsers */
.searchable-dropdown-list::-webkit-scrollbar {
  width: 8px;
}

.searchable-dropdown-list::-webkit-scrollbar-track {
  background: var(--bg);
}

.searchable-dropdown-list::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

.searchable-dropdown-list::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.searchable-dropdown-list[hidden] {
  display: none;
}

.searchable-dropdown-item {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.1s ease;
}

.searchable-dropdown-item:hover {
  background: var(--bg);
  color: var(--text-primary);
}

.searchable-dropdown-item.selected {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent);
  font-weight: 500;
}

.searchable-dropdown-empty {
  padding: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-align: center;
}

/* =============================================================================
   Status Bar — Only visible on error
   ============================================================================= */
.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-bar[hidden] {
  display: none;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--error);
  flex-shrink: 0;
}

/* =============================================================================
   Main Content
   ============================================================================= */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-6);
}

/* =============================================================================
   Results Section
   ============================================================================= */
.results-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.results-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

#resultCount {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.query-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.cache-indicator {
  font-size: var(--text-xs);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: transparent;
  transition: all 0.15s ease;
}

.cache-indicator.cache-hit {
  background: #DCFCE7;
  color: #166534;
  cursor: pointer;
}

.cache-indicator.cache-hit:hover {
  background: #FEE2E2;
  color: #DC2626;
}

.results-table {
  /* Single-scroll layout: let the page scroll, not the results container */
  overflow: visible;
  max-height: none;
}

/* =============================================================================
   Keyword Filter Breadcrumb
   ============================================================================= */
.keyword-filter-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
  border: 1px solid #BFDBFE;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
}

.breadcrumb-label {
  color: var(--text-muted);
}

.breadcrumb-keyword {
  color: var(--accent);
  font-weight: 600;
}

.breadcrumb-clear {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  margin-left: auto;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.breadcrumb-clear:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.breadcrumb-clear svg {
  flex-shrink: 0;
}

/* =============================================================================
   Empty State
   ============================================================================= */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
}

.empty-state-content {
  text-align: center;
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.empty-state-hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.example-query {
  background: none;
  border: none;
  font-family: inherit;
  font-size: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.example-query:hover {
  color: var(--accent-hover);
}

/* =============================================================================
   Platform Badges
   ============================================================================= */
.platform-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
}

.platform-einnsyn { background: #DBEAFE; color: #1E40AF; }
.platform-nye_innsyn { background: #D1FAE5; color: #065F46; }
.platform-360online { background: #FEE2E2; color: #991B1B; }
.platform-onacos { background: #E0E7FF; color: #3730A3; }
.platform-elementscloud { background: #FCE7F3; color: #9D174D; }
.platform-bergen { background: #FEF3C7; color: #92400E; }
.platform-innsynsportal_graphql { background: #CFFAFE; color: #0E7490; }
.platform-oygarden { background: #F3E8FF; color: #6B21A8; }
.platform-embedded_innsyn { background: #ECFDF5; color: #047857; }
.platform-websak_legacy { background: #FFF7ED; color: #C2410C; }
.platform-lofoten { background: #E0F2FE; color: #0369A1; }
.platform-drammen { background: #F5F3FF; color: #5B21B6; }
.platform-ibestad { background: #FDF2F8; color: #BE185D; }
.platform-unknown { background: #F3F4F6; color: #6B7280; }

/* Document type badge */
.doc-type-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
  background: #F3F4F6;
  color: #374151;
  border: 1px solid var(--border);
}

.no-link {
  color: var(--text-muted);
}

/* =============================================================================
   Card Layout (matching public site)
   ============================================================================= */
.cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: var(--space-4);
  padding: var(--space-4);
}

@media (max-width: 480px) {
  .cards-container {
    grid-template-columns: 1fr;
    gap: var(--space-3);
    padding: var(--space-3);
  }
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.result-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.pdf-match-card {
  border-color: #F59E0B;
  background: linear-gradient(to bottom, #FFFBEB 0%, var(--surface) 100%);
}

.pdf-match-card:hover {
  border-color: #D97706;
}

.card-header {
  padding: var(--space-4);
  background: linear-gradient(to bottom, rgba(0,0,0,0.02), transparent);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
  width: 100%;
}

.card-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

.card-badges {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: flex-end;
  max-width: 40%;
}

.card-body {
  padding: var(--space-4);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
}

.card-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  width: 100%;
}

.card-row.card-meta {
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.card-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0; 
}

.card-row.card-meta .card-field {
  flex: 1;
  min-width: 80px;
}

.field-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field-value {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  max-width: 100%;
}

.card-footer {
  padding: var(--space-3) var(--space-4);
  background: rgba(0,0,0,0.02);
  border-top: 1px solid var(--border);
}

.card-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: white;
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.card-link:hover {
  background: var(--accent-hover);
  transform: translateX(2px);
}

.card-link-pdf {
  background: #F59E0B;
}

.card-link-pdf:hover {
  background: #D97706;
}

.card-link-search {
  background: #6366F1;
}

.card-link-search:hover {
  background: #4F46E5;
}

.card-links {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.card-footer .no-link {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-style: italic;
}

/* PDF Match Styling */
.pdf-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
  background: #FEF3C7;
  color: #92400E;
  cursor: help;
}

.pdf-badge svg {
  stroke: #92400E;
  flex-shrink: 0;
}

.pdf-badge-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
  background: #F59E0B;
  color: white;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pdf-badge-link svg {
  stroke: white;
  flex-shrink: 0;
}

.pdf-badge-link:hover {
  background: #D97706;
  transform: scale(1.05);
}

/* =============================================================================
   Pagination
   ============================================================================= */
.pagination {
  padding: var(--space-4);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  position: relative;
}

.pagination-btn {
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-info {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  padding: 0 var(--space-2);
}

.pagination-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-left: var(--space-4);
}

.pagination-hint kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
  font-family: var(--font-mono);
  font-size: 10px;
}

/* Highlight */
mark {
  background: var(--highlight-bg);
  padding: 1px 3px;
  border-radius: 2px;
  border-bottom: 2px solid var(--highlight-border);
}

/* =============================================================================
   Loading & Error States
   ============================================================================= */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-12);
  gap: var(--space-3);
  color: var(--text-muted);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-message {
  background: var(--error-bg);
  color: #991B1B;
  padding: var(--space-4);
  margin: var(--space-4);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--error);
  font-size: var(--text-sm);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.error-message .error-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.error-message .error-content {
  flex: 1;
}

.error-message .error-content strong {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--text-base);
}

.error-message .error-content p {
  margin: 0 0 var(--space-2) 0;
  line-height: 1.5;
}

.error-message.timeout-error {
  background: #FEF3C7;
  color: #92400E;
  border-left-color: #F59E0B;
}

.error-message .error-hint {
  background: rgba(0,0,0,0.05);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  margin-top: var(--space-2);
}

/* Skeleton Loading */
.skeleton-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: var(--space-4);
  padding: var(--space-4);
}

.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  height: 200px;
}

.skeleton-line {
  background: linear-gradient(90deg, var(--border) 25%, var(--bg) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
  height: 14px;
  margin-bottom: var(--space-2);
}

.skeleton-line.title {
  height: 20px;
  width: 70%;
  margin-bottom: var(--space-4);
}

.skeleton-line.short {
  width: 40%;
}

.skeleton-line.medium {
  width: 60%;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Prefetch indicator */
.prefetch-indicator {
  position: absolute;
  right: var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding: 2px 8px;
  background: #EFF6FF;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  animation: pulse 2s ease-in-out infinite;
}

.prefetch-indicator[hidden] {
  display: none;
}

.prefetch-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* Page transition */
.cards-container {
  animation: fadeInUp 0.2s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.placeholder {
  padding: var(--space-12);
  text-align: center;
  color: var(--text-muted);
}

/* =============================================================================
   Responsive
   ============================================================================= */
@media (max-width: 768px) {
  .search-header-inner {
    padding: var(--space-3) var(--space-4);
  }

  .brand {
    display: none;
  }

  .search-container {
    max-width: none;
  }

  .keyboard-hint {
    display: none;
  }

  .search-clear-btn {
    right: var(--space-3);
  }

  .options-toggle span {
    display: none;
  }

  .leads-toggle {
    display: none;
  }

  .results-header {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .leads-buttons-mobile {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    order: 10;
    flex-basis: 100%;
  }

  .leads-buttons-mobile .lead-quick-btn {
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
    gap: 4px;
  }

  .leads-buttons-mobile .lead-quick-btn svg {
    width: 12px;
    height: 12px;
  }

  .leads-panel-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
  }

  .leads-panel-label {
    display: none;
  }

  .leads-panel .leads-buttons {
    width: 100%;
    gap: var(--space-1);
  }

  .leads-panel .lead-quick-btn {
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
    gap: 4px;
  }

  .leads-panel .lead-quick-btn svg {
    width: 12px;
    height: 12px;
  }

  .search-options-inner {
    flex-direction: column;
    align-items: stretch;
    padding: var(--space-3) var(--space-4);
  }

  .field-toggles {
    flex-wrap: wrap;
  }

  .filter-controls {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
  }

  .searchable-dropdown,
  .platform-selector.searchable-dropdown,
  .kommune-selector.searchable-dropdown,
  .fylke-selector.searchable-dropdown {
    width: 100%;
    min-width: 0;
  }

  .searchable-dropdown input[type="text"] {
    width: 100%;
  }

  .main-content {
    padding: var(--space-4);
  }

  .results-table {
    max-height: none;
  }
}

@media (max-width: 480px) {
  .search-input-wrapper input {
    height: 40px;
    font-size: var(--text-sm);
  }
  
  .toggle-chip {
    font-size: var(--text-xs);
    padding: var(--space-1) var(--space-2);
  }
}

/* =============================================================================
   Print
   ============================================================================= */
@media print {
  .search-header {
    position: static;
  }

  .options-toggle,
  .keyboard-hint {
    display: none;
  }

  .results-table {
    max-height: none;
    overflow: visible;
  }
}

/* =============================================================================
   Login Overlay
   ============================================================================= */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-overlay[hidden] {
  display: none;
}

/* Auth loading state - show spinner while checking auth */
.login-overlay.auth-loading .login-form,
.login-overlay.auth-loading .login-hint {
  display: none;
}

.auth-spinner-container {
  display: flex;
  justify-content: center;
  padding: var(--space-6) 0;
}

.login-overlay:not(.auth-loading) .auth-spinner-container {
  display: none;
}

.auth-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: auth-spin 0.8s linear infinite;
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-8);
  max-width: 380px;
  width: 90%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
}

.login-header {
  text-align: center;
  margin-bottom: var(--space-6);
}

.login-header h1 {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.login-header p {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form-group label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input {
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.login-error {
  background: var(--error-bg);
  color: var(--error);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  text-align: center;
}

.login-error[hidden] {
  display: none;
}

.login-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.login-button:hover:not(:disabled) {
  background: var(--accent-hover);
}

.login-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.button-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.button-spinner[hidden] {
  display: none;
}

.loading-status {
  text-align: center;
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-muted);
  animation: pulse 2s ease-in-out infinite;
}

.loading-status[hidden] {
  display: none;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.login-hint {
  text-align: center;
  margin-top: var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* =============================================================================
   User Menu
   ============================================================================= */
.user-menu {
  position: relative;
}

.user-menu[hidden] {
  display: none;
}

.user-button {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.user-button:hover {
  background: var(--bg);
  border-color: var(--border-strong);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  min-width: 120px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  z-index: 200;
}

.user-dropdown[hidden] {
  display: none;
}

.logout-button {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: inherit;
  color: var(--error);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.logout-button:hover {
  background: var(--error-bg);
}

@media (max-width: 640px) {
  .user-button span {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* =============================================================================
   Technical Details & New Styles
   ============================================================================= */

/* Technical Details Section */
.tech-details {
  margin-top: var(--space-3);
  border-top: 1px solid var(--border);
  padding-top: var(--space-1);
  font-size: var(--text-xs);
}

.tech-details summary {
  padding: var(--space-2) 0;
  cursor: pointer;
  color: var(--text-muted);
  user-select: none;
  font-weight: 500;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  transition: color 0.15s ease;
}

/* Custom triangle/marker */
.tech-details summary::-webkit-details-marker {
  display: none;
}

.tech-details summary::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  margin-right: var(--space-2);
  transition: transform 0.2s ease;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.tech-details[open] summary::before {
  transform: rotate(45deg);
}

.tech-details summary:hover {
  color: var(--accent);
}

.tech-details summary:hover::before {
  color: var(--accent);
}

.tech-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--bg);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  border: 1px solid var(--border);
}

@media (min-width: 600px) {
  .tech-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .tech-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.tech-item {
  color: var(--text-secondary);
  font-size: var(--text-xs);
  background: var(--surface);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tech-label {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tech-value {
  font-weight: 500;
  color: var(--text-primary);
  overflow-wrap: break-word;
  word-break: break-word;
  line-height: 1.4;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--text-primary);
  background: rgba(0,0,0,0.04);
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.05);
}

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 500;
    white-space: nowrap;
    background: #F3E8FF;
    color: #6B21A8;
    border: 1px solid #E9D5FF;
}

/* Ensure full width field spans across */
.card-field.full-width {
    width: 100%;
}

/* =============================================================================
   Advanced Filters & Exclusions
   ============================================================================= */
.search-options-inner {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: var(--space-4) !important;
}

.search-filters-primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  position: relative;
}

/* Clear All Filters Button */
.clear-all-filters-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 12px;
  background: #FEE2E2;
  border: 1px solid #FCA5A5;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: #991B1B;
  cursor: pointer;
  transition: all 0.15s;
  position: absolute;
  top: -8px;
  right: 0;
  z-index: 10;
}

.clear-all-filters-btn:hover {
  background: #FEF2F2;
  border-color: #EF4444;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

.clear-all-filters-btn[hidden] {
  display: none;
}

.search-filters-secondary {
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
  margin-top: -4px;
}

.exclusion-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.exclusion-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: 500;
}

.exclusion-presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.preset-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); /* Pill shape */
  font-size: var(--text-xs);
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.preset-chip:hover {
  border-color: var(--border-strong);
  background: var(--bg);
}

.preset-chip.active {
  background: #FEE2E2; /* Light red background for exclusion */
  border-color: #EF4444;
  color: #991B1B;
  font-weight: 500;
}

.preset-chip .count-badge {
  background: rgba(0,0,0,0.1);
  padding: 0 4px;
  border-radius: 4px;
  font-size: 10px;
}

.manage-presets-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 4px 10px;
  background: transparent;
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.manage-presets-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(59, 130, 246, 0.05);
}

/* =============================================================================
   Modal Styles
   ============================================================================= */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
  padding: var(--space-4);
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  box-shadow: 
    0 0 0 1px rgba(0, 0, 0, 0.05),
    0 20px 25px -5px rgba(0, 0, 0, 0.15), 
    0 10px 10px -5px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  padding: var(--space-5) var(--space-6);
  background: linear-gradient(to bottom, #F8FAFC, var(--surface));
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.modal-icon {
  color: var(--accent);
}

.modal-header h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
}

/* Form Styles */
.new-filter-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.form-row {
  display: flex;
  gap: var(--space-4);
}

.form-group-name {
  flex: 1;
  min-width: 0;
}

.form-group-color {
  width: 170px;
  flex-shrink: 0;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-group label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group label svg {
  flex-shrink: 0;
}

.label-include {
  color: #16A34A !important;
}

.label-include svg {
  stroke: #16A34A;
}

.label-exclude {
  color: #DC2626 !important;
}

.label-exclude svg {
  stroke: #DC2626;
}

.modal-body input[type="text"],
.modal-body textarea,
.modal-body select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--text-sm);
  background: var(--surface);
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.modal-body input[type="text"]:hover,
.modal-body textarea:hover,
.modal-body select:hover {
  border-color: var(--border-strong);
}

.modal-body input[type="text"]:focus,
.modal-body textarea:focus,
.modal-body select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.modal-body textarea {
  resize: vertical;
  min-height: 60px;
}

/* Color select with preview */
.color-select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.color-preview {
  display: none; /* Hide the color circle */
}

.color-select-wrapper select {
  width: 100%;
  padding: 10px 40px 10px 12px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
}

.color-select-wrapper select:hover {
  border-color: var(--border-strong);
}

.color-select-wrapper select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

/* Form Actions */
.form-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-2);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.btn-secondary {
  flex: 0 0 auto;
  padding: 10px 20px;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-primary {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--accent), #3B82F6);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-hover), #2563EB);
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Existing Filters Section */
.existing-filters {
  margin-top: var(--space-6);
  border-top: 1px solid var(--border);
  padding-top: var(--space-5);
}

.existing-filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.existing-filters-header h4 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0;
}

.existing-filters-header h4 svg {
  color: var(--text-muted);
}

.filter-count {
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 999px;
}

.filter-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 240px;
  overflow-y: auto;
}

.filter-list:empty::before {
  content: "Ingen filtre opprettet ennå";
  display: block;
  text-align: center;
  padding: var(--space-6);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.filter-list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
}

.filter-list-item:hover {
  border-color: var(--border-strong);
  background: var(--surface);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.filter-item-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8), 0 1px 2px rgba(0, 0, 0, 0.1);
}

.filter-item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.filter-item-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.filter-item-words {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  font-size: var(--text-xs);
}

.filter-words {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 500;
}

.filter-words-include {
  background: rgba(22, 163, 74, 0.1);
  color: #16A34A;
}

.filter-words-exclude {
  background: rgba(220, 38, 38, 0.1);
  color: #DC2626;
}

.filter-item-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  opacity: 0;
  transition: opacity 0.15s;
}

.filter-list-item:hover .filter-item-actions {
  opacity: 1;
}

.filter-edit-btn,
.filter-delete-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-edit-btn:hover {
  background: rgba(59, 130, 246, 0.1);
  color: #2563EB;
}

.filter-delete-btn:hover {
  background: rgba(220, 38, 38, 0.1);
  color: #DC2626;
}

.no-filters-message {
  text-align: center;
  padding: var(--space-6);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Date Selector Styles */
.date-selector {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.date-selector input {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: inherit;
  background: var(--surface);
  color: var(--text-primary);
  /* Fixed width for date inputs */
  width: 130px; 
}

.date-selector input:focus {
    outline: none;
    border-color: var(--accent);
}

.date-sep {
    color: var(--text-muted);
}

/* Filter Item Actions */
.filter-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.edit-filter-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  opacity: 0.7;
}

.edit-filter-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--accent);
  opacity: 1;
}

/* =============================================================================
   Year Facets Bar
   ============================================================================= */
.year-facets-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: linear-gradient(to bottom, #F8FAFC, var(--surface));
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: thin;
}

.year-facets-bar[hidden] {
  display: none;
}

.year-facets-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.year-facets-chips {
  display: flex;
  gap: var(--space-2);
  flex-wrap: nowrap;
}

.year-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.year-chip:hover {
  border-color: var(--accent);
  background: #EFF6FF;
  color: var(--accent);
  transform: translateY(-1px);
}

.year-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.year-chip.active:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.year-chip .year-count {
  font-size: var(--text-xs);
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.year-chip.active .year-count {
  background: rgba(255, 255, 255, 0.25);
}

.year-facets-clear {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 6px 12px;
  background: transparent;
  border: 1px dashed var(--border-strong);
  border-radius: 20px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.year-facets-clear:hover {
  border-color: var(--error);
  color: var(--error);
  background: var(--error-bg);
}

.year-facets-clear[hidden] {
  display: none;
}

/* =============================================================================
   Results Header Actions
   ============================================================================= */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.leads-buttons-mobile {
  display: none;
}

.results-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.stats-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.stats-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #EFF6FF;
}

.stats-toggle.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.stats-toggle[hidden] {
  display: none;
}

/* =============================================================================
   Statistics Panel
   ============================================================================= */
.stats-panel {
  background: linear-gradient(to bottom, #F1F5F9, var(--surface));
  border-bottom: 1px solid var(--border);
  padding: var(--space-4);
  animation: slideDown 0.2s ease;
}

.stats-panel[hidden] {
  display: none;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.stats-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.stats-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.stats-card-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stats-card-icon {
  color: var(--accent);
}

.stats-bar-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  cursor: pointer;
  padding: 4px 8px;
  margin: 0 -8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.stats-bar-item:hover {
  background: #EFF6FF;
}

.stats-bar-item-active {
  background: #DBEAFE;
  border: 1px solid var(--accent);
  margin: 0 -9px;
}

.stats-bar-item-active:hover {
  background: #BFDBFE;
}

.stats-bar-item-active .stats-bar-label {
  color: var(--accent);
  font-weight: 600;
}

.stats-bar-item:last-child {
  margin-bottom: 0;
}

.stats-bar-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  min-width: 100px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-bar-container {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.stats-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.stats-bar-count {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  min-width: 40px;
  text-align: right;
}

/* Sparkline */
.stats-sparkline {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 40px;
  padding: var(--space-2) 0;
}

.spark-bar {
  flex: 1;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  min-height: 3px;
  transition: height 0.3s ease, background 0.15s ease;
  position: relative;
}

.spark-bar:hover {
  background: var(--accent-hover);
}

.spark-bar::after {
  content: attr(data-label);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.spark-bar:hover::after {
  opacity: 1;
}

.spark-labels {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-1);
}

.spark-labels span {
  font-size: 10px;
  color: var(--text-muted);
}

/* Single month display */
.stats-card-compact {
  min-width: auto;
}

.stats-month-single {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-2) 0;
}

.stats-month-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}

.stats-month-count {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Filtered state indicator */
.results-filtered-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: #FEF3C7;
  border-bottom: 1px solid #FCD34D;
  font-size: var(--text-sm);
  color: #92400E;
}

.results-filtered-indicator[hidden] {
  display: none;
}

.filtered-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 8px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  font-weight: 500;
}

/* =============================================================================
   Search History Dropdown
   ============================================================================= */
.search-history-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
  z-index: 100;
  animation: dropdownIn 0.15s ease;
  max-height: 400px;
  overflow-y: auto;
}

.search-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: #F8FAFC;
}

.search-history-header span {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.clear-history-btn {
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.clear-history-btn:hover {
  border-color: var(--error);
  color: var(--error);
  background: var(--error-bg);
}

.search-history-list {
  display: flex;
  flex-direction: column;
}

.search-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: none;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
  border-bottom: 1px solid var(--border);
}

.search-history-item:last-child {
  border-bottom: none;
}

.search-history-item:hover {
  background: #EFF6FF;
}

.history-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.history-query {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.history-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: var(--space-3);
}


/* =============================================================================
   Leads Toggle Button - Prominent orange button
   ============================================================================= */
.leads-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #EA580C;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  color: white;
  cursor: pointer;
  transition: all 0.15s ease;
}

.leads-toggle:hover {
  background: #C2410C;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.3);
}

.leads-toggle[aria-expanded="true"] {
  background: #C2410C;
}

.leads-toggle[aria-expanded="true"] svg {
  stroke: white;
}

.leads-toggle svg {
  stroke: white;
}

/* =============================================================================
   Leads Panel (Collapsible) - Clean minimal design
   ============================================================================= */
.leads-panel {
  border-top: 1px solid var(--border);
  background: #FEFCE8;
  overflow: hidden;
  animation: slideDown 0.2s ease-out;
}

.leads-panel[hidden] {
  display: none;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.leads-panel-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-6);
}

.leads-panel-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.leads-icon {
  stroke: #CA8A04;
}

.leads-panel-label span {
  font-size: var(--text-sm);
  font-weight: 500;
  color: #78716C;
}

.leads-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

/* Empty state hint for leads */
.empty-state-leads-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding: var(--space-3);
  background: #FEFCE8;
  border: 1px dashed #CA8A04;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: #78716C;
}

.empty-state-leads-hint svg {
  stroke: #CA8A04;
  flex-shrink: 0;
}

.empty-state-leads-hint strong {
  font-weight: 600;
}

/* =============================================================================
   Lead Quick Buttons - Clean pill style matching webpage design
   ============================================================================= */
.lead-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.lead-quick-btn .lead-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.lead-quick-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(59, 130, 246, 0.04);
}

.lead-quick-btn:active {
  transform: scale(0.98);
}

/* Critical tier - orange with bolt icon */
.lead-quick-btn.lead-tier-critical {
  border-color: #FDBA74;
  background: #FFF7ED;
  color: #EA580C;
}
.lead-quick-btn.lead-tier-critical .lead-icon {
  fill: #EA580C;
}
.lead-quick-btn.lead-tier-critical:hover {
  background: #EA580C;
  border-color: #EA580C;
  color: white;
}
.lead-quick-btn.lead-tier-critical:hover .lead-icon {
  fill: white;
}

/* High tier - same as critical style */
.lead-quick-btn.lead-tier-high {
  border-color: #FDBA74;
  background: #FFF7ED;
  color: #EA580C;
}
.lead-quick-btn.lead-tier-high .lead-icon {
  fill: #EA580C;
}
.lead-quick-btn.lead-tier-high:hover {
  background: #EA580C;
  border-color: #EA580C;
  color: white;
}
.lead-quick-btn.lead-tier-high:hover .lead-icon {
  fill: white;
}

/* Medium tier - yellow/amber */
.lead-quick-btn.lead-tier-medium {
  border-color: #E5E7EB;
  background: var(--surface);
  color: var(--text-secondary);
}
.lead-quick-btn.lead-tier-medium:hover {
  background: #CA8A04;
  border-color: #CA8A04;
  color: white;
}

/* Low tier - gray/neutral */
.lead-quick-btn.lead-tier-low {
  border-color: #E5E7EB;
  background: var(--surface);
  color: var(--text-secondary);
}
.lead-quick-btn.lead-tier-low:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Admin tier - subtle gray */
.lead-quick-btn.lead-tier-admin {
  border-color: #E5E7EB;
  background: var(--surface);
  color: var(--text-muted);
}
.lead-quick-btn.lead-tier-admin:hover {
  background: #6B7280;
  border-color: #6B7280;
  color: white;
}

/* =============================================================================
   Lead Score Badge - Clean text badge design
   ============================================================================= */
.lead-score-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--lead-badge-color, #EA580C);
  color: white;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  white-space: nowrap;
  cursor: help;
  letter-spacing: 0.02em;
}

.lead-score-badge .lead-icon {
  width: 10px;
  height: 10px;
  fill: white;
  flex-shrink: 0;
}

/* Lead Highlight in text */
mark.lead-highlight {
  background: linear-gradient(135deg, rgba(234, 88, 12, 0.15), rgba(234, 88, 12, 0.1));
  border-bottom: 2px solid #EA580C;
  padding: 0 2px;
  border-radius: 2px;
}


/* Result card styling based on relevance score */
.result-card.lead-critical,
.result-card.lead-high,
.result-card.relevance-high {
  border-left: 4px solid #EA580C;
  background: linear-gradient(90deg, rgba(234, 88, 12, 0.03) 0%, transparent 50%);
}

.result-card.lead-medium,
.result-card.relevance-medium {
  border-left: 4px solid #CA8A04;
  background: linear-gradient(90deg, rgba(202, 138, 4, 0.02) 0%, transparent 50%);
}

.result-card.lead-low,
.result-card.relevance-low {
  border-left: 4px solid #6B7280;
}

.result-card.lead-negative {
  opacity: 0.7;
}

/* Remove distracting animation */
.result-card.lead-critical,
.result-card.lead-high {
  /* No animation - cleaner look */
}

@keyframes leadPulse {
  0%, 100% { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
  50% { box-shadow: 0 4px 12px rgba(220, 38, 38, 0.15); }
}

/* =============================================================================
   Lead Indicator (Filter buttons in results header)
   ============================================================================= */
.lead-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  background: transparent;
  border: none;
  font-size: var(--text-sm);
  margin-right: var(--space-2);
}

.lead-indicator[hidden] {
  display: none;
}

.lead-indicator-label {
  display: none; /* Hidden - labels are now in buttons */
}

/* Lead count filter buttons - clean pill style */
.lead-count {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 20px;
  font-weight: 500;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--surface);
  color: var(--text-secondary);
  white-space: nowrap;
}

.lead-count-num {
  font-weight: 600;
  opacity: 0.7;
}

.lead-count:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.lead-count:active {
  transform: scale(0.98);
}

.lead-count .lead-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

/* All button (default/clear filter) */
.lead-count-all {
  background: var(--surface);
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

.lead-count-all:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.lead-count-all.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* High priority button */
.lead-count-high {
  border-color: #FDBA74;
  background: #FFF7ED;
  color: #EA580C;
}

.lead-count-high .lead-icon {
  fill: #EA580C;
}

.lead-count-high:hover {
  background: #FED7AA;
  border-color: #EA580C;
}

.lead-count-high.active {
  background: #EA580C;
  color: white;
  border-color: #C2410C;
}

.lead-count-high.active .lead-icon {
  fill: white;
}

/* Medium priority button */
.lead-count-medium {
  border-color: #FDE68A;
  background: #FFFBEB;
  color: #CA8A04;
}

.lead-count-medium:hover {
  background: #FDE68A;
  border-color: #CA8A04;
}

.lead-count-medium.active {
  background: #CA8A04;
  color: white;
  border-color: #A16207;
}

/* Low priority button */
.lead-count-low {
  border-color: #E5E7EB;
  background: var(--surface);
  color: #6B7280;
}

.lead-count-low:hover {
  background: #F3F4F6;
  border-color: #6B7280;
}

.lead-count-low.active {
  background: #6B7280;
  color: white;
  border-color: #4B5563;
}

/* =============================================================================
   Polish — Edge Shadows & Micro Animations
   ============================================================================= */

/* Inner edge shadows for depth on containers */
.results-section {
  box-shadow: 
    0 1px 3px rgba(0, 0, 0, 0.05),
    0 4px 12px rgba(0, 0, 0, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.search-header {
  box-shadow: 
    0 1px 0 var(--border),
    0 4px 16px rgba(0, 0, 0, 0.04);
}

/* Cards — layered shadows for floating effect */
.result-card {
  box-shadow: 
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 2px 4px rgba(0, 0, 0, 0.02),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: 
    transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.22s ease,
    border-color 0.18s ease;
}

.result-card:hover {
  box-shadow: 
    0 8px 24px rgba(0, 0, 0, 0.08),
    0 4px 8px rgba(0, 0, 0, 0.04),
    0 0 0 1px rgba(59, 130, 246, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transform: translateY(-3px);
}

.result-card:active {
  transform: translateY(-1px);
  transition-duration: 0.1s;
}

/* Modal — dramatic shadow */
.modal-card {
  box-shadow: 
    0 25px 50px -12px rgba(0, 0, 0, 0.25),
    0 12px 24px -8px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  animation: modalIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Buttons — microinteractions */
button, .toggle-chip, .preset-chip, .year-chip {
  transition: 
    transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.options-toggle:hover,
.leads-toggle:hover,
.stats-toggle:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.options-toggle:active,
.leads-toggle:active,
.stats-toggle:active,
.pagination-btn:active,
.card-link:active {
  transform: scale(0.97);
  transition-duration: 0.08s;
}

/* Search input — glowing focus */
.search-input-wrapper input:focus {
  box-shadow: 
    0 0 0 3px rgba(59, 130, 246, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.06),
    inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* Clear button — subtle pop */
.search-clear-btn {
  transition: 
    transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
    background 0.12s ease,
    border-color 0.12s ease,
    color 0.12s ease;
}

.search-clear-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.search-clear-btn:active {
  transform: scale(0.95);
}

/* Chips — springy hover */
.toggle-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.toggle-chip:active {
  transform: translateY(0) scale(0.98);
}

.toggle-chip:has(input:checked) {
  box-shadow: 
    0 2px 8px rgba(59, 130, 246, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Preset chips — exclusion filter */
.preset-chip:hover {
  transform: translateY(-1px);
}

.preset-chip.active {
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.2);
  animation: chipActivate 0.3s ease;
}

@keyframes chipActivate {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Card links — arrow slide */
.card-link {
  position: relative;
  overflow: hidden;
}

.card-link::after {
  content: '→';
  position: absolute;
  right: 12px;
  opacity: 0;
  transform: translateX(-8px);
  transition: 
    opacity 0.2s ease,
    transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.card-link:hover {
  padding-right: 32px;
}

.card-link:hover::after {
  opacity: 1;
  transform: translateX(0);
}

/* Badge pop animation */
.platform-badge, .doc-type-badge, .pdf-badge, .status-badge {
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.platform-badge:hover, .doc-type-badge:hover, .pdf-badge:hover, .status-badge:hover {
  transform: scale(1.05);
}

/* Dropdown shadow */
.searchable-dropdown-list,
.user-dropdown,
.search-history-dropdown {
  box-shadow: 
    0 10px 40px rgba(0, 0, 0, 0.12),
    0 4px 12px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  animation: dropdownIn 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dropdownIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Dropdown items — smooth highlight */
.searchable-dropdown-item {
  transition: 
    background 0.12s ease,
    color 0.12s ease,
    padding-left 0.15s ease;
}

.searchable-dropdown-item:hover {
  padding-left: calc(var(--space-3) + 4px);
}

/* Year chips — playful bounce */
.year-chip:active {
  transform: scale(0.95);
}

.year-chip.active {
  animation: yearSelect 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes yearSelect {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* Stats bars — animated fill */
.stats-bar-fill {
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  animation: barGrow 0.5s ease-out;
}

@keyframes barGrow {
  from {
    transform: scaleX(0);
    transform-origin: left;
  }
  to {
    transform: scaleX(1);
  }
}

/* Filter badge pulse when active */
.filter-active-badge {
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { 
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
  }
  50% { 
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0);
  }
}

/* Clear all filters button — attention grab */
.clear-all-filters-btn {
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.15);
  animation: filterClearPulse 2.5s ease-in-out infinite;
}

@keyframes filterClearPulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

.clear-all-filters-btn:hover {
  animation: none;
}

/* Login button — inviting glow */
.login-button {
  box-shadow: 
    0 4px 14px rgba(59, 130, 246, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: 
    transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.2s ease,
    background 0.15s ease;
}

.login-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 
    0 6px 20px rgba(59, 130, 246, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.login-button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 
    0 2px 8px rgba(59, 130, 246, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Loading spinner — smoother */
.loading-spinner, .spinner, .auth-spinner, .button-spinner {
  animation: spin 0.7s cubic-bezier(0.4, 0.15, 0.6, 0.85) infinite;
}

/* Skeleton shimmer — refined */
.skeleton-line {
  background: linear-gradient(
    90deg, 
    var(--border) 0%, 
    rgba(255,255,255,0.6) 40%, 
    rgba(255,255,255,0.6) 60%, 
    var(--border) 100%
  );
  background-size: 300% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Mark/highlight — subtle glow */
mark {
  transition: 
    background 0.2s ease,
    box-shadow 0.2s ease;
}

mark:hover {
  background: #FDE68A;
  box-shadow: 0 0 0 2px #FCD34D;
}

/* Results section — fade in cards staggered */
.cards-container .result-card {
  animation: cardFadeIn 0.35s ease-out both;
}

.cards-container .result-card:nth-child(1) { animation-delay: 0ms; }
.cards-container .result-card:nth-child(2) { animation-delay: 30ms; }
.cards-container .result-card:nth-child(3) { animation-delay: 60ms; }
.cards-container .result-card:nth-child(4) { animation-delay: 90ms; }
.cards-container .result-card:nth-child(5) { animation-delay: 120ms; }
.cards-container .result-card:nth-child(6) { animation-delay: 150ms; }
.cards-container .result-card:nth-child(n+7) { animation-delay: 180ms; }

@keyframes cardFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Focus ring — consistent glow */
:focus-visible {
  outline: none;
  box-shadow: 
    0 0 0 2px var(--surface),
    0 0 0 4px var(--accent);
}

/* Input fields — refined shadows */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  box-shadow: 
    0 0 0 3px rgba(59, 130, 246, 0.12),
    inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Pagination buttons — depth */
.pagination-btn {
  box-shadow: 
    0 1px 2px rgba(0, 0, 0, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.pagination-btn:hover:not(:disabled) {
  box-shadow: 
    0 4px 12px rgba(59, 130, 246, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Brand logo — subtle hover */
.brand {
  transition: 
    transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.2s ease;
}

.brand:hover {
  transform: scale(1.02);
}

.brand:active {
  transform: scale(0.98);
}

/* Tech details — smooth reveal */
.tech-details[open] .tech-grid {
  animation: techReveal 0.25s ease-out;
}

@keyframes techReveal {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Reduced motion — respect user preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =============================================================================
   Smart Filters System
   ============================================================================= */

.search-filters-secondary {
  padding: var(--space-3) var(--space-6);
  border-top: 1px solid var(--border);
  background: linear-gradient(to bottom, #F8FAFC, var(--surface));
}

.smart-filters-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: 1400px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.smart-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

/* Smart Filter Chip */
.smart-filter-chip {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  user-select: none;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.smart-filter-chip .chip-main {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.smart-filter-chip .chip-main:hover {
  background: rgba(0, 0, 0, 0.03);
}

.smart-filter-chip .chip-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--filter-color, var(--accent));
  flex-shrink: 0;
}

.smart-filter-chip .chip-actions {
  display: flex;
  align-items: center;
  padding-right: 4px;
  gap: 2px;
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  transition: opacity 0.2s, max-width 0.2s ease;
}

.smart-filter-chip:hover .chip-actions {
  opacity: 1;
  max-width: 80px;
}

.smart-filter-chip .chip-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.smart-filter-chip .chip-action:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--text-primary);
}

.smart-filter-chip .chip-edit:hover {
  background: rgba(59, 130, 246, 0.15);
  color: #2563EB;
}

.smart-filter-chip .chip-delete:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #DC2626;
}

.smart-filter-chip:hover {
  border-color: var(--border-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.smart-filter-chip.active {
  background: color-mix(in srgb, var(--filter-color, var(--accent)) 12%, white);
  border-color: var(--filter-color, var(--accent));
  color: var(--filter-color, var(--accent));
  box-shadow: 0 2px 8px color-mix(in srgb, var(--filter-color, var(--accent)) 25%, transparent);
}

.smart-filter-chip.active .chip-main:hover {
  background: rgba(0, 0, 0, 0.05);
}

.smart-filter-chip.active .chip-color-dot {
  box-shadow: 0 0 0 2px white, 0 0 0 3px var(--filter-color, var(--accent));
}

.smart-filter-chip.active .chip-action {
  color: var(--filter-color, var(--accent));
}

.smart-filter-chip.active .chip-action:hover {
  background: rgba(255, 255, 255, 0.5);
}

.smart-filter-chip.active .chip-edit:hover {
  background: rgba(255, 255, 255, 0.6);
  color: #2563EB;
}

.smart-filter-chip.active .chip-delete:hover {
  background: rgba(255, 255, 255, 0.6);
  color: #DC2626;
}

.smart-filter-chip .chip-name {
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Chip badges */
.chip-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  color: var(--text-muted);
}

.smart-filter-chip.active .chip-badge {
  background: rgba(255, 255, 255, 0.5);
  color: inherit;
}

.chip-badge-include {
  color: #16A34A;
}

.chip-badge-exclude {
  color: #DC2626;
}

/* No filters hint */
.no-filters-hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
  padding: 4px 0;
}

/* Add Filter Button */
.add-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(59, 130, 246, 0.04));
  border: 1.5px dashed var(--accent);
  border-radius: 999px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  transition: all 0.2s ease;
}

.add-filter-btn:hover {
  border-style: solid;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.08));
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
  transform: translateY(-1px);
}

.add-filter-btn:active {
  transform: translateY(0);
}

.add-filter-btn svg {
  flex-shrink: 0;
}

/* Modal Improvements for Smart Filters */
.modal-card-wide {
  max-width: 520px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.modal-close:hover {
  background: var(--bg);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
}

/* Filter Form */
.new-filter-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.form-row {
  display: flex;
  gap: var(--space-4);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
}

.form-group-color {
  flex: 0 0 110px;
}

.form-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: inherit;
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 64px;
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.cancel-filter-btn {
  padding: var(--space-2) var(--space-4);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.cancel-filter-btn:hover {
  background: var(--bg);
  border-color: var(--border-strong);
}

.save-filter-btn {
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: white;
  cursor: pointer;
  transition: background 0.15s;
}

.save-filter-btn:hover {
  background: var(--accent-hover);
}

/* Filter List in Modal */
.existing-filters {
  margin-top: var(--space-6);
  border-top: 1px solid var(--border);
  padding-top: var(--space-4);
}

.filter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}

.filter-item:hover {
  border-color: var(--border-strong);
}

.filter-item-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  flex: 1;
}

.filter-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.filter-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}

.filter-words {
  display: flex;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
}

.filter-words .include-preview {
  color: #16A34A;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.filter-words .exclude-preview {
  color: #DC2626;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

/* Empty state when no filters */
.smart-filter-chips:empty + .add-filter-btn::after {
  content: " for å komme i gang";
  font-weight: 400;
}

/* Mobile responsive */
@media (max-width: 640px) {
  .search-filters-secondary {
    padding: var(--space-3);
  }
  
  .smart-filters-bar {
    gap: var(--space-2);
  }
  
  .smart-filter-chip {
    font-size: var(--text-xs);
  }
  
  .smart-filter-chip .chip-main {
    padding: 6px 10px;
    gap: 6px;
  }
  
  .smart-filter-chip .chip-color-dot {
    width: 8px;
    height: 8px;
  }
  
  .smart-filter-chip .chip-name {
    max-width: 100px;
  }
  
  .smart-filter-chip .chip-actions {
    opacity: 1;
    max-width: 60px;
  }
  
  .smart-filter-chip .chip-action {
    width: 24px;
    height: 24px;
  }
  
  .form-row {
    flex-direction: column;
    gap: var(--space-3);
  }
  
  .form-group-color {
    flex: 1;
  }
}
