:root {
  --color-primary: #1E40AF;
  --color-primary-light: #3B82F6;
  --color-primary-dark: #1E3A8A;
  --color-primary-bg: #EFF6FF;

  --color-secondary: #065F46;
  --color-success: #059669;
  --color-error: #DC2626;

  --color-bg: #FFFFFF;
  --color-bg-alt: #F9FAFB;
  --color-text: #111827;
  --color-text-muted: #6B7280;
  --color-border: #E5E7EB;
  --color-border-focus: #1E40AF;

  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  --font-heading: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 20px rgba(30, 64, 175, 0.08);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
  --shadow-hover: 0 8px 30px rgba(30, 64, 175, 0.15);

  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
  --transition-slow: 500ms ease;

  --max-width: 1200px;
  --header-height: 64px;
}

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

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

body {
  font-family: var(--font-body);
  color: var(--color-text);
  background-color: var(--color-bg-alt);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-light);
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
}

input, select {
  font-family: inherit;
  font-size: 1rem;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

/* Header Styles */
.header {
  background: linear-gradient(135deg, #1E3A8A 0%, #2563EB 50%, #3B82F6 100%);
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 3px solid #F59E0B;
  height: var(--header-height);
  display: flex;
  align-items: center;
  box-shadow: 0 4px 20px rgba(30, 58, 138, 0.3);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.logo {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 800;
  color: white;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.logo-icon-svg {
  width: 32px;
  height: 32px;
  color: white;
}

/* Main Content */
.main-content {
  padding: var(--space-2xl) 0;
  min-height: calc(100vh - var(--header-height) - 200px);
}

/* Tool Card */
.tool-card {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-xl);
  margin-bottom: var(--space-xl);
  animation: fadeInUp 600ms ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tool-title {
  font-size: 1.875rem;
  margin-bottom: var(--space-lg);
  color: var(--color-primary-dark);
  text-align: center;
}

.selectors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-select,
.form-input {
  height: 48px;
  padding: 0 var(--space-md);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  transition: all var(--transition-fast);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236B7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m19.5 8.25-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
  padding-right: 40px;
}

.form-select:focus,
.form-input:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.form-input-wrapper {
  position: relative;
}

.form-input-icon {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--color-text-muted);
  pointer-events: none;
}

.form-input.search-input {
  height: 56px;
  padding-left: 48px;
  font-size: 1.0625rem;
  border-radius: var(--radius-lg);
}

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

/* Ad Slots */
.ad-slot {
  background: var(--color-bg-alt);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  margin: var(--space-xl) 0;
  text-align: center;
  position: relative;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-slot::before {
  content: 'Advertisement';
  position: absolute;
  top: 8px;
  left: 12px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.ad-slot-banner {
  min-height: 90px;
  max-width: 728px;
  margin: 0 auto;
}

.ad-slot-sidebar {
  min-height: 250px;
  margin-top: var(--space-xl);
}

.ad-slot-inline {
  min-height: 100px;
  margin: var(--space-lg) 0;
}

.ad-slot-text {
  min-height: 80px;
  background: linear-gradient(to right, transparent, var(--color-border), transparent);
  border: none;
  padding: var(--space-md) var(--space-xl);
  font-style: italic;
  color: var(--color-text-muted);
  font-size: 0.9375rem;
}

@media (min-width: 1024px) {
  .ad-slot-sidebar-desktop {
    display: block;
  }
}

@media (max-width: 1023px) {
  .ad-slot-sidebar-desktop {
    display: none !important;
  }
}

/* Results Section */
.results-section {
  animation: fadeInUp 400ms ease-out;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.results-count {
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.results-table {
  width: 100%;
  background: var(--color-bg);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}

.results-table thead {
  background: var(--color-primary-bg);
  border-bottom: 2px solid var(--color-primary-light);
}

.results-table th {
  padding: var(--space-md);
  text-align: left;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary-dark);
}

.results-table td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9375rem;
  transition: background var(--transition-fast);
}

.results-table tbody tr:nth-child(even) {
  background: var(--color-bg-alt);
}

.results-table tbody tr:hover {
  background: var(--color-primary-bg);
}

.results-table tbody tr:last-child td {
  border-bottom: none;
}

.postal-code-cell {
  font-family: 'Courier New', monospace;
  font-weight: 700;
  color: var(--color-primary);
  font-size: 1rem;
  letter-spacing: 0.03em;
}

.copy-btn {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  background: var(--color-primary-bg);
  color: var(--color-primary);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.9375rem;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  transition: all var(--transition-fast);
  border: 2px solid transparent;
  cursor: pointer;
}

.copy-btn:hover {
  background: var(--color-primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.copy-btn.copied {
  background: var(--color-success);
  color: white;
  border-color: var(--color-success);
  animation: pulse 500ms ease-in-out;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.copy-btn svg {
  width: 18px;
  height: 18px;
}

.no-results {
  text-align: center;
  padding: var(--space-3xl);
  color: var(--color-text-muted);
  font-size: 1.0625rem;
}

.no-results svg {
  width: 64px;
  height: 64px;
  margin-bottom: var(--space-md);
  opacity: 0.3;
}

/* SEO Content */
.seo-section {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  margin-top: var(--space-2xl);
  box-shadow: var(--shadow-sm);
}

.seo-title {
  font-size: 2rem;
  color: var(--color-primary-dark);
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-md);
  border-bottom: 3px solid var(--color-primary-light);
}

.seo-subtitle {
  font-size: 1.5rem;
  color: var(--color-primary);
  margin: var(--space-xl) 0 var(--space-md);
}

.seo-content p {
  margin-bottom: var(--space-lg);
  font-size: 1.0625rem;
  line-height: 1.8;
  color: var(--color-text);
  text-align: justify;
}

.seo-content strong {
  color: var(--color-primary-dark);
  font-weight: 600;
}

/* Layout Grid for Desktop (Sidebar + Main Content) */
.layout-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
}

@media (min-width: 1024px) {
  .layout-grid {
    grid-template-columns: 1fr 300px;
  }

  .sidebar {
    position: sticky;
    top: calc(var(--header-height) + var(--space-xl));
    align-self: start;
  }
}

/* Footer */
.footer {
  background: var(--color-text);
  color: var(--color-bg-alt);
  padding: var(--space-2xl) 0 var(--space-lg);
  margin-top: var(--space-3xl);
}

.footer-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-lg);
  justify-content: center;
  margin-bottom: var(--space-lg);
}

.footer-link {
  color: var(--color-bg-alt);
  font-size: 0.9375rem;
  transition: color var(--transition-fast);
  font-weight: 500;
}

.footer-link:hover {
  color: var(--color-primary-light);
  text-decoration: underline;
}

.footer-disclaimer {
  text-align: center;
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.6;
  max-width: 800px;
  margin: 0 auto;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 32px;
  right: 32px;
  background: var(--color-success);
  color: white;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 600;
  z-index: 9999;
  animation: slideInRight 300ms ease-out;
  font-size: 0.9375rem;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast.hiding {
  animation: slideOutRight 300ms ease-in forwards;
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

.toast svg {
  width: 20px;
  height: 20px;
}

/* Loading State */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

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

.loading-overlay {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--color-text-muted);
}

/* Responsive Design */
@media (max-width: 767px) {
  .tool-card {
    padding: var(--space-lg);
  }

  .tool-title {
    font-size: 1.5rem;
  }

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

  .form-select,
  .form-input {
    height: 44px;
  }

  .search-input {
    height: 50px;
  }

  .results-table th,
  .results-table td {
    padding: var(--space-sm) var(--space-sm);
    font-size: 0.875rem;
  }

  .postal-code-cell {
    font-size: 0.9375rem;
  }

  .copy-btn {
    width: 32px;
    height: 32px;
  }

  .seo-section {
    padding: var(--space-lg);
  }

  .seo-title {
    font-size: 1.625rem;
  }

  .seo-subtitle {
    font-size: 1.25rem;
  }

  .seo-content p {
    font-size: 1rem;
  }

  .ad-slot {
    padding: var(--space-lg);
    min-height: 60px;
  }

  .ad-slot-banner {
    min-height: 60px;
  }

  .footer-links {
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
  }

  .toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .selectors-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Utility Classes */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center {
  text-align: center;
}

.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-md); }
.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-md); }

/* Data Accuracy Notice - Footer Style */
.data-notice {
  text-align: center;
  padding: var(--space-sm) var(--space-md);
  margin: var(--space-md) 0 0 0;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  border-top: 1px solid var(--color-border);
  background: transparent;
  border-radius: 0;
}

.data-notice-icon {
  font-size: 1rem;
  margin-right: 0.25rem;
}

.data-notice-content {
  display: inline;
}

.data-notice-content strong {
  color: var(--color-text);
}

/* Cookie Consent Banner */
.cookie-consent {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-surface);
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  padding: 1rem;
  border-top: 1px solid var(--color-border);
}

.cookie-consent-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.cookie-consent p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-text);
}

.cookie-consent a {
  color: var(--color-primary);
  text-decoration: underline;
}

.cookie-consent-buttons {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.cookie-btn {
  padding: 0.5rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-size: 0.875rem;
  transition: opacity 0.2s;
}

.cookie-btn:hover {
  opacity: 0.9;
}

.cookie-btn-primary {
  background: var(--color-primary);
  color: white;
}

.cookie-btn-secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

/* Ad Container */
.ad-container {
  margin: 2rem 0;
  text-align: center;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px dashed var(--color-border);
}

.ad-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Print Styles */
@media print {
  .header,
  .ad-slot,
  .ad-container,
  .sidebar,
  .footer,
  .copy-btn,
  .cookie-consent {
    display: none !important;
  }

  .main-content {
    padding: 0;
  }

  .tool-card {
    box-shadow: none;
    border: 1px solid #000;
  }

  .results-table {
    box-shadow: none;
    border: 1px solid #000;
  }
}

@media (max-width: 768px) {
  .cookie-consent-content {
    flex-direction: column;
    text-align: center;
  }

  .ad-container {
    min-height: 60px;
    margin: 1rem 0;
  }
}
