/* =============================================================================
   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);
}

.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 var(--space-4) 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);
}

.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;
}

/* 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;
}

.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);
}

/* =============================================================================
   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;
}

/* =============================================================================
   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;
}

.cache-indicator.cache-hit {
  background: #DCFCE7;
  color: #166534;
}

.results-table {
  overflow-y: auto;
  max-height: calc(100vh - 220px);
}

/* =============================================================================
   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-block;
  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-link {
  display: inline-block;
  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: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);
}

.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);
}

/* 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);
}

.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;
  }

  .options-toggle span {
    display: none;
  }

  .search-options-inner {
    flex-direction: column;
    align-items: stretch;
    padding: var(--space-3) var(--space-4);
  }

  .field-toggles {
    flex-wrap: wrap;
  }

  .main-content {
    padding: var(--space-4);
  }

  .results-table {
    max-height: calc(100vh - 280px);
  }
}

@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;
}

.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 {
  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;
}

.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;
}

.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(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

.modal-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
}

.form-group {
  margin-bottom: var(--space-4);
}

.form-group label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

.modal-body input[type="text"],
.modal-body textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--text-sm);
  transition: border-color 0.15s;
}

.modal-body input[type="text"]:focus,
.modal-body textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.save-filter-btn {
  width: 100%;
  padding: 8px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.save-filter-btn:hover {
  background: var(--accent-hover);
}

.existing-filters {
  margin-top: var(--space-6);
  border-top: 1px solid var(--border);
  padding-top: var(--space-4);
}

.existing-filters h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}

.filter-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.filter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.filter-item-info {
  display: flex;
  flex-direction: column;
}

.filter-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
}

.filter-words {
  font-size: var(--text-xs);
  color: var(--text-muted);
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.delete-filter-btn {
  background: none;
  border: none;
  color: var(--error);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  opacity: 0.7;
}

.delete-filter-btn:hover {
  background: var(--error-bg);
  opacity: 1;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
