/* licit — Professional UI with serious colors, animations, and responsive design */

:root {
  /* Colors - Light Mode */
  --color-bg: #FAFAFA;
  --color-fg: #18181B;
  --color-muted: #71717A;
  --color-faint: #A1A1AA;
  --color-border: #E4E4E7;
  --color-brand: #0052FF;
  --color-brand-hover: #0044CC;
  --color-brand-light: #E0EEFF;
  --color-brand-dark: #0039A0;
  --color-success: #16A34A;
  --color-success-light: #DCFCE7;
  --color-error: #DC2626;
  --color-error-light: #FEE2E2;
  --color-warning: #D97706;
  --color-warning-light: #FEF3C7;

  /* Semantic Colors */
  --color-bg-card: #FFFFFF;
  --color-bg-hover: #F4F4F5;
  --color-bg-code: #F4F4F5;
  --color-brand-alpha: rgba(0, 82, 255, 0.1);
  --color-success-alpha: rgba(22, 163, 74, 0.1);
  --color-error-alpha: rgba(220, 38, 38, 0.1);

  /* Typography */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", SFMono-Regular, ui-monospace, "Cascadia Code", "Fira Code", Menlo, monospace;

  /* Spacing */
  --sp-xs: 0.25rem;
  --sp-sm: 0.5rem;
  --sp-md: 1rem;
  --sp-lg: 2rem;
  --sp-xl: 4rem;
  --sp-2xl: 6rem;

  /* Border Radius */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Container Widths */
  --max-w-sm: 640px;
  --max-w-md: 768px;
  --max-w-lg: 1024px;
  --max-w-xl: 1280px;
  --max-w-2xl: 1536px;

  /* Transitions */
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 350ms;
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: all var(--duration-normal) var(--ease-out);
}

[data-theme="dark"] {
  /* Colors - Dark Mode */
  --color-bg: #0A0A0B;
  --color-fg: #F4F4F5;
  --color-muted: #A1A1AA;
  --color-faint: #71717A;
  --color-border: #27272A;
  --color-brand: #4488FF;
  --color-brand-hover: #3B82F6;
  --color-brand-light: #1E3A8A;
  --color-brand-dark: #60A5FA;
  --color-success: #22C55E;
  --color-success-light: #166534;
  --color-error: #EF4444;
  --color-error-light: #991B1B;
  --color-warning: #F59E0B;
  --color-warning-light: #92400E;

  /* Semantic Colors - Dark Mode */
  --color-bg-card: #18181B;
  --color-bg-hover: #27272A;
  --color-bg-code: #18181B;
  --color-brand-alpha: rgba(68, 136, 255, 0.15);
  --color-success-alpha: rgba(34, 197, 94, 0.15);
  --color-error-alpha: rgba(239, 68, 68, 0.15);

  /* Shadows - Dark Mode */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 10px 10px -5px rgba(0, 0, 0, 0.5);
}

/* --- Reset --- */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  height: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  font-family: var(--font-sans);
  color: var(--color-fg);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Typography --- */

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--color-fg);
}

a {
  color: var(--color-fg);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color var(--duration-fast);
}

a:hover {
  color: var(--color-brand);
}

.mono {
  font-family: var(--font-mono);
}

.muted {
  color: var(--color-muted);
}

.faint {
  color: var(--color-faint);
}

/* --- Layout --- */

.container {
  width: 100%;
  max-width: var(--max-w-sm);
  margin: 0 auto;
  padding: 0 var(--sp-md);
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* --- Navigation --- */

nav {
  padding: var(--sp-md) 0;
  transition: padding var(--duration-normal);
}

nav.scrolled {
  padding: var(--sp-sm) 0;
  background: var(--color-bg-card);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.brand:hover {
  color: var(--color-fg);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
}

.nav-links a {
  font-size: 0.875rem;
  text-decoration: none;
  color: var(--color-muted);
  padding: var(--sp-xs) var(--sp-sm);
  border-radius: var(--radius-sm);
  position: relative;
  transition: var(--transition-base);
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--color-fg);
  background: var(--color-bg-hover);
}

.nav-links a.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: var(--sp-sm);
  right: var(--sp-sm);
  height: 2px;
  background: var(--color-brand);
  border-radius: var(--radius-full);
}

/* Hamburger (mobile) */

.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--sp-xs);
  z-index: 101;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--color-fg);
  transition: transform var(--duration-normal), opacity var(--duration-normal);
  border-radius: var(--radius-full);
}

.hamburger.open span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.hamburger.open span:nth-child(2) {
  opacity: 0;
}

.hamburger.open span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* Theme Toggle */

.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  cursor: pointer;
  font-size: 1rem;
  padding: var(--sp-xs) var(--sp-sm);
  color: var(--color-muted);
  line-height: 1;
  transition: var(--transition-base);
  border-radius: var(--radius-sm);
}

.theme-toggle:hover {
  border-color: var(--color-fg);
  color: var(--color-fg);
}

/* Mobile Navigation */

@media (max-width: 600px) {
  .hamburger {
    display: flex;
  }

  .nav-links {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-bg);
    flex-direction: column;
    justify-content: center;
    gap: var(--sp-xl);
    z-index: 100;
    padding: var(--sp-xl);
    transform: translateX(100%);
    transition: transform var(--duration-normal) var(--ease-out);
  }

  .nav-links.open {
    transform: translateX(0);
  }

  .nav-links a {
    font-size: 1.25rem;
    padding: var(--sp-sm) var(--sp-md);
  }

  .theme-toggle {
    position: fixed;
    top: var(--sp-md);
    right: var(--sp-md);
    z-index: 102;
  }
}

/* User Dropdown */

.user-dropdown {
  position: relative;
  margin-left: var(--sp-sm);
}

.user-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--sp-xs) var(--sp-sm);
  border-radius: var(--radius-sm);
  color: var(--color-fg);
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition-base);
}

.user-dropdown-trigger:hover {
  background: var(--color-bg-hover);
}

.dropdown-arrow {
  transition: transform var(--duration-normal);
}

.user-dropdown-menu:not(.hidden) ~ .user-dropdown-trigger .dropdown-arrow,
.user-dropdown-trigger[aria-expanded="true"] .dropdown-arrow {
  transform: rotate(180deg);
}

.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 200px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  padding: var(--sp-xs);
}

.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--sp-sm) var(--sp-md);
  color: var(--color-fg);
  text-decoration: none;
  border-radius: var(--radius-xs);
  font-size: 0.875rem;
  transition: var(--transition-base);
}

.dropdown-item:hover {
  background: var(--color-bg-hover);
}

.dropdown-item-danger {
  color: var(--color-error);
}

.dropdown-item-danger:hover {
  background: var(--color-error-light);
}

@media (max-width: 600px) {
  .user-dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    padding: 0;
    margin-top: var(--sp-sm);
  }

  .dropdown-item {
    font-size: 1.1rem;
    padding: var(--sp-md);
  }
}

/* --- Buttons --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-xs);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  padding: var(--sp-sm) var(--sp-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  color: var(--color-fg);
  text-decoration: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-brand);
  color: var(--color-brand);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

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

.btn-primary:hover {
  background: var(--color-brand-hover);
  border-color: var(--color-brand-hover);
  color: white;
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: transparent;
  color: var(--color-fg);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
  background: var(--color-brand-light);
}

.btn-danger {
  background: var(--color-error);
  color: white;
  border-color: var(--color-error);
}

.btn-danger:hover {
  background: #B91C1C;
  border-color: #B91C1C;
}

.btn-sm {
  font-size: 0.8rem;
  padding: var(--sp-xs) var(--sp-sm);
}

.btn-lg {
  padding: var(--sp-md) var(--sp-lg);
  font-size: 1rem;
}

.btn-icon {
  width: 18px;
  height: 18px;
}

/* --- Forms --- */

.form-page {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--sp-xl) var(--sp-md);
}

.form-group {
  margin-bottom: var(--sp-md);
}

.form-group label {
  display: block;
  margin-bottom: var(--sp-xs);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-hint {
  display: block;
  margin-top: var(--sp-xs);
  font-size: 0.8rem;
  color: var(--color-muted);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: var(--sp-sm) var(--sp-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: var(--color-bg-card);
  color: var(--color-fg);
  transition: var(--transition-base);
  font-family: var(--font-sans);
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px var(--color-brand-alpha);
}

.form-error {
  display: none;
  background: var(--color-error-light);
  color: var(--color-error);
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: var(--sp-md);
  animation: shake 0.3s ease-in-out;
}

.form-error.visible {
  display: block;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.form-actions {
  margin-top: var(--sp-lg);
  display: flex;
  gap: var(--sp-md);
}

/* --- Cards --- */

.card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--sp-lg);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-base);
}

.card:hover {
  border-color: var(--color-brand);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* --- Badges --- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-estado {
  background: var(--color-brand-alpha);
  color: var(--color-brand);
  border-color: var(--color-brand);
}

.badge-estado.adjudicado::before {
  background: var(--color-success);
}

.badge-estado.desierto::before {
  background: var(--color-error);
}

.badge-active {
  background: var(--color-success-alpha);
  color: var(--color-success);
  border-color: var(--color-success);
}

.badge-revoked {
  background: var(--color-error-alpha);
  color: var(--color-error);
  border-color: var(--color-error);
}

.badge-info {
  background: var(--color-brand-light);
  color: var(--color-brand-dark);
  border-color: var(--color-brand);
}

/* --- Tables --- */

.table-wrapper {
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  flex: 1;
  min-height: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-bg-card);
  font-size: 0.875rem;
}

table th,
table td {
  padding: var(--sp-sm) var(--sp-md);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

table th {
  font-weight: 600;
  color: var(--color-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--color-bg);
  position: sticky;
  top: 0;
}

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

table td .mono {
  font-size: 0.8rem;
  color: var(--color-muted);
}

/* --- Hero Section --- */

.hero-section {
  padding: var(--sp-2xl) 0;
  background: linear-gradient(135deg, var(--color-bg) 0%, var(--color-brand-light) 100%);
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 80% 20%, var(--color-brand-alpha) 0%, transparent 50%);
  opacity: 0.5;
}

.hero-container {
  max-width: var(--max-w-xl);
  margin: 0 auto;
  padding: 0 var(--sp-lg);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-xl);
  align-items: center;
  position: relative;
  z-index: 1;
}

.hero-content {
  opacity: 0;
  animation: fadeInUp var(--duration-slow) var(--ease-out) 0.1s forwards;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  padding: var(--sp-xs) var(--sp-sm);
  background: var(--color-brand);
  color: white;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: var(--sp-md);
  box-shadow: var(--shadow-md);
}

.hero-badge-icon {
  font-size: 1rem;
}

.hero-title {
  margin-bottom: var(--sp-lg);
}

.hero-title-main {
  display: block;
  font-family: var(--font-mono);
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--color-fg);
  margin-bottom: var(--sp-sm);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.hero-title-sub {
  display: block;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--color-muted);
  line-height: 1.3;
}

.hero-description {
  font-size: 1.125rem;
  color: var(--color-muted);
  line-height: 1.7;
  margin-bottom: var(--sp-xl);
  max-width: 540px;
}

.hero-cta {
  display: flex;
  gap: var(--sp-md);
  flex-wrap: wrap;
}

/* --- Spain Map --- */

.hero-map {
  position: relative;
  width: 100%;
  height: 500px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  opacity: 0;
  animation: fadeIn var(--duration-slow) var(--ease-out) 0.3s forwards;
  z-index: 1;
}

.hero-map .leaflet-container {
  width: 100%;
  height: 100%;
}

.map-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-md);
  z-index: 1001;
}

.map-loading .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.map-loading span:not(.spinner) {
  color: var(--color-muted);
  font-size: 0.875rem;
}

.map-loading.hidden {
  display: none;
}

.map-legend {
  position: absolute;
  bottom: var(--sp-md);
  left: var(--sp-md);
  display: flex;
  gap: var(--sp-md);
  padding: var(--sp-sm) var(--sp-md);
  background: rgba(255,255,255,0.9);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--color-fg);
  backdrop-filter: blur(8px);
  z-index: 1000;
}

[data-theme="dark"] .map-legend {
  background: rgba(10,10,11,0.9);
}

.map-legend-item {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
}

.map-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.map-legend-dot.low {
  background: var(--color-border);
}

.map-legend-dot.medium {
  background: var(--color-brand-light);
}

.map-legend-dot.high {
  background: var(--color-brand);
}

.leaflet-bar a {
  background-color: var(--color-bg-card) !important;
  color: var(--color-fg) !important;
  border-color: var(--color-border) !important;
}

[data-theme="dark"] .leaflet-bar a {
  background-color: #1f2937 !important;
  color: #f9fafb !important;
  border-color: #374151 !important;
}

.leaflet-bar a:hover {
  background-color: var(--color-brand-light) !important;
}

.leaflet-bar a.leaflet-disabled {
  background-color: var(--color-bg-card) !important;
  opacity: 0.5;
}

/* --- Stats Section --- */

.stats-section {
  padding: var(--sp-2xl) 0;
  background: var(--color-bg);
}

.stats-container {
  max-width: var(--max-w-xl);
  margin: 0 auto;
  padding: 0 var(--sp-lg);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-md);
}

.stat-card {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-lg);
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-base);
}

.stat-card:hover {
  border-color: var(--color-brand);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  font-size: 1.5rem;
}

.stat-icon-licitaciones {
  background: var(--color-brand-light);
  color: var(--color-brand);
}

.stat-icon-organos {
  background: var(--color-brand-light);
  color: var(--color-brand);
}

.stat-icon-empresas {
  background: var(--color-success-light);
  color: var(--color-success);
}

.stat-icon-presupuesto {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.stat-content {
  flex: 1;
  min-width: 0;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--sp-xs);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 600;
  color: var(--color-fg);
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-xs);
}

.stat-unit {
  font-size: 1rem;
  color: var(--color-muted);
  font-weight: 400;
}

.stat-trend {
  font-size: 0.875rem;
  color: var(--color-success);
  font-weight: 500;
}

/* --- Features Section --- */

.features-section {
  padding: var(--sp-2xl) 0;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
}

.features-container {
  max-width: var(--max-w-xl);
  margin: 0 auto;
  padding: 0 var(--sp-lg);
}

.section-header {
  text-align: center;
  margin-bottom: var(--sp-2xl);
}

.section-title {
  font-size: 2rem;
  font-weight: 600;
  color: var(--color-fg);
  margin-bottom: var(--sp-sm);
  letter-spacing: -0.02em;
}

.section-subtitle {
  font-size: 1.125rem;
  color: var(--color-muted);
  line-height: 1.6;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-lg);
}

.feature-card {
  padding: var(--sp-lg);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: var(--transition-base);
  opacity: 0;
}

.feature-card:nth-child(1) { animation: fadeInUp var(--duration-normal) var(--ease-out) 0.2s forwards; }
.feature-card:nth-child(2) { animation: fadeInUp var(--duration-normal) var(--ease-out) 0.3s forwards; }
.feature-card:nth-child(3) { animation: fadeInUp var(--duration-normal) var(--ease-out) 0.4s forwards; }
.feature-card:nth-child(4) { animation: fadeInUp var(--duration-normal) var(--ease-out) 0.5s forwards; }
.feature-card:nth-child(5) { animation: fadeInUp var(--duration-normal) var(--ease-out) 0.6s forwards; }

.feature-card:hover {
  border-color: var(--color-brand);
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.feature-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-brand-light);
  color: var(--color-brand);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-md);
}

.feature-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-fg);
  margin-bottom: var(--sp-sm);
}

.feature-description {
  font-size: 0.9375rem;
  color: var(--color-muted);
  line-height: 1.6;
}

/* --- Problem Section --- */

.problem-section {
  padding: var(--sp-2xl) 0;
  background: linear-gradient(135deg, var(--color-brand-light) 0%, var(--color-bg) 100%);
}

.problem-container {
  max-width: var(--max-w-lg);
  margin: 0 auto;
  padding: 0 var(--sp-lg);
}

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

.problem-title {
  font-size: 2rem;
  font-weight: 600;
  color: var(--color-fg);
  margin-bottom: var(--sp-xl);
  letter-spacing: -0.02em;
}

.problem-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-lg);
}

.problem-card {
  padding: var(--sp-lg);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-align: left;
  transition: var(--transition-base);
}

.problem-card:hover {
  border-color: var(--color-brand);
  box-shadow: var(--shadow-md);
  transform: translateX(4px);
}

.problem-icon {
  font-size: 2rem;
  margin-bottom: var(--sp-sm);
}

.problem-card h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-fg);
  margin-bottom: var(--sp-sm);
}

.problem-card p {
  font-size: 0.9375rem;
  color: var(--color-muted);
  line-height: 1.6;
}

/* --- Search Page --- */

.search-page {
  width: 100%;
  margin: 0 auto;
  padding: var(--sp-xl) var(--sp-md);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.search-form {
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  padding: var(--sp-lg);
  margin-bottom: var(--sp-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.search-row {
  display: flex;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}

.search-row input[type="text"] {
  flex: 1;
  padding: var(--sp-sm) var(--sp-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: var(--color-bg);
  color: var(--color-fg);
  transition: var(--transition-base);
  outline: none;
}

.search-row input[type="text"]:focus {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px var(--color-brand-alpha);
}

.search-options {
  display: flex;
  gap: var(--sp-md);
  align-items: center;
  margin-bottom: var(--sp-md);
  flex-wrap: wrap;
}

.search-options label {
  font-weight: 500;
  color: var(--color-muted);
  font-size: 0.875rem;
}

.search-options select {
  padding: var(--sp-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--color-bg);
  color: var(--color-fg);
  cursor: pointer;
  outline: none;
}

.filters-toggle {
  margin-bottom: var(--sp-md);
}

.filters-toggle button {
  background: none;
  border: none;
  color: var(--color-brand);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
}

.filters-toggle button::after {
  content: "▼";
  font-size: 0.625rem;
  transition: transform var(--duration-normal);
}

.filters-toggle button.open::after {
  transform: rotate(180deg);
}

.filters-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--duration-slow) var(--ease-out);
}

.filters-panel.visible {
  max-height: 2000px;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-lg);
  padding-top: var(--sp-md);
  border-top: 1px solid var(--color-border);
}

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

.filter-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-muted);
}

.filter-group input[type="text"],
.filter-group input[type="number"],
.filter-group input[type="date"],
.filter-group select {
  padding: var(--sp-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--color-bg);
  color: var(--color-fg);
  transition: var(--transition-base);
  outline: none;
}

.filter-group input:focus,
.filter-group select:focus {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 2px var(--color-brand-alpha);
}

.range-group {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
}

.range-group span {
  color: var(--color-muted);
  font-size: 0.875rem;
}

.checkbox-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--sp-xs);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  padding: var(--sp-xs);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background var(--duration-fast);
  border-radius: var(--radius-xs);
}

.checkbox-item:hover {
  background: var(--color-bg-hover);
}

.checkbox-item input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--color-brand);
}

.filter-actions {
  display: flex;
  gap: var(--sp-md);
  margin-top: var(--sp-lg);
}

/* --- Search Results --- */

.search-page .search-results {
  flex: 1;
  max-height: none;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-lg);
  padding-bottom: var(--sp-md);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
  gap: var(--sp-sm);
  flex-shrink: 0;
}

.results-header .total {
  font-size: 0.875rem;
  color: var(--color-muted);
}

.results-header .total strong {
  color: var(--color-fg);
  font-size: 1rem;
}

.export-actions {
  display: flex;
  gap: var(--sp-sm);
}

.btn-export {
  padding: var(--sp-xs) var(--sp-sm);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--color-muted);
  cursor: pointer;
  transition: var(--transition-base);
}

.btn-export:hover {
  background: var(--color-bg-hover);
  color: var(--color-fg);
  border-color: var(--color-brand);
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-bg-card);
  font-size: 0.875rem;
}

.results-table thead {
  position: sticky;
  top: 0;
  background: var(--color-bg);
  z-index: 10;
}

.results-table th {
  font-weight: 600;
  color: var(--color-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--color-bg);
  padding: var(--sp-md);
  text-align: left;
  border-bottom: 2px solid var(--color-border);
}

.results-table td {
  padding: var(--sp-md);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

.results-table tbody tr {
  transition: var(--transition-base);
  opacity: 0;
  animation: fadeInUp var(--duration-normal) var(--ease-out) forwards;
}

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

.table-cell-title {
  min-width: 250px;
}

.table-cell-title a {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-fg);
  text-decoration: none;
  margin-bottom: var(--sp-xs);
  line-height: 1.4;
}

.table-cell-title a:hover {
  color: var(--color-brand);
}

.table-cell-title .doc-icon {
  display: inline-block;
  margin-left: var(--sp-xs);
  font-size: 1rem;
}

.table-cell-amount {
  min-width: 140px;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.table-cell-amount .amount-row {
  display: block;
  margin-bottom: var(--sp-xs);
}

.table-cell-amount .amount-label {
  color: var(--color-muted);
  font-size: 0.75rem;
  display: block;
}

.table-cell-amount .amount-value {
  font-weight: 600;
  color: var(--color-fg);
}

.table-cell-amount .baja-value {
  color: var(--color-success);
  font-weight: 500;
}

.table-cell-estado {
  min-width: 140px;
}

.table-cell-estado .badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs);
}

.table-cell-meta {
  min-width: 200px;
  font-size: 0.875rem;
}

.table-cell-meta .meta-row {
  display: block;
  margin-bottom: var(--sp-xs);
  color: var(--color-muted);
}

.table-cell-meta .meta-label {
  font-weight: 500;
  color: var(--color-fg);
}

.table-cell-fechas {
  min-width: 140px;
  font-size: 0.8rem;
  color: var(--color-muted);
}

.table-cell-fechas .fecha-row {
  display: block;
  margin-bottom: var(--sp-xs);
}

.table-cell-fechas .fecha-label {
  display: block;
  font-size: 0.75rem;
  color: var(--color-faint);
}

/* Mobile responsive table */
@media (max-width: 768px) {
  .results-table thead {
    display: none;
  }

  .results-table tr {
    display: block;
    margin-bottom: var(--sp-md);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--sp-md);
  }

  .results-table td {
    display: block;
    padding: var(--sp-xs) 0;
    border: none;
    text-align: left;
  }

  .results-table td::before {
    content: attr(data-label);
    display: block;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--sp-xs);
  }

  .table-cell-title {
    margin-bottom: var(--sp-sm);
  }

  .table-cell-title a {
    font-size: 1.125rem;
  }
}

/* --- Pagination --- */
.pagination {
  display: flex;
  justify-content: center;
  gap: var(--sp-md);
  margin-top: var(--sp-xl);
  flex-shrink: 0;
}

.pagination button {
  padding: var(--sp-sm) var(--sp-lg);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--color-fg);
  cursor: pointer;
  transition: var(--transition-base);
}

.pagination button:hover:not(:disabled) {
  background: var(--color-bg-hover);
  border-color: var(--color-brand);
  color: var(--color-brand);
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- States --- */

.empty-state,
.loading-state,
.error-state {
  text-align: center;
  padding: var(--sp-2xl);
  color: var(--color-muted);
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-md);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.error-state {
  color: var(--color-error);
  background: var(--color-error-light);
  border-radius: var(--radius-md);
}

/* --- Detail Page --- */

.detail-page {
  max-width: var(--max-w-lg);
  margin: 0 auto;
  padding: var(--sp-xl) var(--sp-md);
}

.detail-header {
  margin-bottom: var(--sp-xl);
  padding-bottom: var(--sp-lg);
  border-bottom: 1px solid var(--color-border);
}

.detail-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-fg);
  margin-bottom: var(--sp-md);
  line-height: 1.3;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-sm);
  align-items: center;
}

.detail-meta .badge {
  font-size: 0.875rem;
  padding: 4px 10px;
}

.detail-meta span {
  font-size: 0.875rem;
  color: var(--color-muted);
}

.detail-meta a {
  font-size: 0.875rem;
  color: var(--color-brand);
  text-decoration: none;
}

.detail-meta a:hover {
  text-decoration: underline;
}

.detail-section {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--sp-lg);
  margin-bottom: var(--sp-lg);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-base);
}

.detail-section:hover {
  box-shadow: var(--shadow-md);
}

.detail-section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-fg);
  margin-bottom: var(--sp-lg);
  padding-bottom: var(--sp-sm);
  border-bottom: 1px solid var(--color-border);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-lg);
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}

.field-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field-value {
  font-size: 0.9375rem;
  color: var(--color-fg);
  line-height: 1.5;
}

.field-value.amount {
  font-weight: 600;
  color: var(--color-fg);
  font-size: 1.125rem;
}

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

/* --- Timeline --- */

.timeline {
  position: relative;
  padding-left: var(--sp-lg);
}

.timeline::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 4px;
  bottom: 4px;
  width: 1px;
  background: var(--color-border);
}

.timeline-item {
  position: relative;
  margin-bottom: var(--sp-md);
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--sp-lg) + 3px);
  top: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-brand);
}

.timeline-item .tl-date {
  font-size: 0.75rem;
  color: var(--color-faint);
  margin-bottom: 2px;
}

.timeline-item .tl-label {
  font-size: 0.875rem;
}

/* --- Documents --- */

.doc-list {
  list-style: none;
}

.doc-list li {
  padding: var(--sp-xs) 0;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--color-border);
}

.doc-list li:last-child {
  border-bottom: none;
}

.doc-list li a {
  text-decoration: none;
  color: var(--color-brand);
}

.doc-list li a:hover {
  text-decoration: underline;
}

.doc-list .doc-tipo {
  font-size: 0.7rem;
  color: var(--color-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: var(--sp-sm);
}

/* --- Dashboard/Panel --- */

/* --- Detail Page Mobile Accordion --- */

@media (max-width: 767px) {
  .detail-section {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--sp-md);
    overflow: hidden;
  }

  .detail-section > h2 {
    position: relative;
    cursor: pointer;
    padding: var(--sp-md);
    margin: 0;
    background: var(--color-bg-card);
    border-bottom: 1px solid var(--color-border);
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-fg);
  }

  .detail-section > h2::after {
    content: "+";
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-muted);
    transition: transform 0.2s ease;
  }

  .detail-section.expanded > h2::after {
    transform: rotate(45deg);
  }

  .detail-section > h2:hover {
    background: var(--color-bg-hover);
  }

  .detail-section.expanded > h2 {
    border-bottom-color: var(--color-border);
  }

  .detail-grid {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 var(--sp-md);
  }

  .detail-section.expanded .detail-grid {
    max-height: 2000px;
    padding: var(--sp-md);
  }

  .detail-table,
  .timeline,
  .doc-list,
  #d-lotes-list,
  #d-similares-list,
  #d-productos-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 var(--sp-md);
  }

  .detail-section.expanded .detail-table,
  .detail-section.expanded .timeline,
  .detail-section.expanded .doc-list,
  .detail-section.expanded #d-lotes-list,
  .detail-section.expanded #d-similares-list,
  .detail-section.expanded #d-productos-content {
    max-height: 2000px;
    padding: var(--sp-md);
  }

  #d-productos-loading,
  #d-productos-empty {
    padding: var(--sp-md);
  }
}

.dashboard {
  padding: var(--sp-xl) var(--sp-md);
}

.dashboard h1 {
  margin-bottom: var(--sp-xs);
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-fg);
}

.dashboard-subtitle {
  color: var(--color-muted);
  margin-bottom: var(--sp-xl);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-lg);
  flex-wrap: wrap;
  gap: var(--sp-sm);
}

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-fg);
}

.key-display {
  display: none;
  background: var(--color-bg-card);
  border: 1px solid var(--color-brand);
  border-radius: var(--radius-md);
  padding: var(--sp-lg);
  margin-bottom: var(--sp-xl);
}

.key-display.visible {
  display: block;
  animation: fadeIn var(--duration-normal) var(--ease-out);
}

.key-display p {
  margin-bottom: var(--sp-md);
  color: var(--color-muted);
}

.key-value {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  background: var(--color-bg);
  padding: var(--sp-md);
  border-radius: var(--radius-sm);
  margin-bottom: var(--sp-md);
  overflow-x: auto;
}

.key-value code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--color-fg);
  white-space: nowrap;
}

.key-warning {
  font-size: 0.875rem;
  color: var(--color-warning);
}

/* --- Content Pages (Legal, etc.) --- */

.content-page {
  padding: var(--sp-2xl) 0;
  max-width: var(--max-w-md);
  margin: 0 auto;
}

.content-page h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-fg);
  margin-bottom: var(--sp-xl);
  padding-bottom: var(--sp-md);
  border-bottom: 1px solid var(--color-border);
}

.content-page h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-fg);
  margin-top: var(--sp-2xl);
  margin-bottom: var(--sp-md);
}

.content-page h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-fg);
  margin-top: var(--sp-xl);
  margin-bottom: var(--sp-sm);
}

.content-page p {
  color: var(--color-fg);
  line-height: 1.7;
  margin-bottom: var(--sp-md);
}

.content-page ul {
  margin-bottom: var(--sp-md);
  padding-left: var(--sp-lg);
}

.content-page li {
  color: var(--color-fg);
  line-height: 1.6;
  margin-bottom: var(--sp-xs);
}

.content-page strong {
  color: var(--color-fg);
  font-weight: 600;
}

/* --- Reports Grid --- */

.reports-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-md);
  margin-top: var(--sp-xl);
}

.report-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--sp-lg);
  text-decoration: none;
  transition: var(--transition-base);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.report-card:hover {
  border-color: var(--color-brand);
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.report-card:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  max-width: 50%;
  justify-self: center;
}

.report-icon {
  font-size: 2rem;
  margin-bottom: var(--sp-md);
}

.report-card h3 {
  margin: 0 0 var(--sp-sm) 0;
  color: var(--color-fg);
  font-size: 1.25rem;
  font-weight: 600;
}

.report-card p {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.9375rem;
}

/* --- Footer --- */

footer {
  padding: var(--sp-xl) 0;
  border-top: 1px solid var(--color-border);
  margin-top: var(--sp-xl);
  background: var(--color-bg-card);
  flex-shrink: 0;
}

footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--color-faint);
  flex-wrap: wrap;
  gap: var(--sp-md);
}

footer a {
  color: var(--color-faint);
}

footer a:hover {
  color: var(--color-muted);
}

.footer-legal {
  font-size: 0.75rem;
  color: var(--color-faint);
  display: flex;
  gap: var(--sp-md);
  flex-wrap: wrap;
}

.footer-legal a {
  color: var(--color-faint);
  text-decoration: underline;
}

.footer-summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-sm);
  align-items: baseline;
  padding-top: var(--sp-md);
  margin-top: var(--sp-md);
  border-top: 1px solid var(--color-border);
  font-size: 0.75rem;
  width: 100%;
}

.summary-loading {
  color: var(--color-faint);
}

.summary-footer-label {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.65rem;
  color: var(--color-faint);
  margin-right: var(--sp-sm);
}

.summary-footer-count strong {
  font-weight: 600;
  color: var(--color-fg);
}

.summary-sep {
  color: var(--color-border);
}

/* --- Cookie Banner --- */

.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-bg-card);
  border-top: 1px solid var(--color-border);
  padding: var(--sp-md) 0;
  z-index: 1000;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  animation: slideUp var(--duration-slow) var(--ease-out);
}

.cookie-banner .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-md);
  flex-wrap: wrap;
}

.cookie-banner p {
  margin: 0;
  flex: 1;
  min-width: 200px;
  font-size: 0.875rem;
}

.cookie-buttons {
  display: flex;
  gap: var(--sp-sm);
}

/* --- Toast Notifications --- */

#toast-container {
  position: fixed;
  bottom: var(--sp-lg);
  right: var(--sp-lg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  max-width: 360px;
}

.toast {
  padding: var(--sp-sm) var(--sp-md);
  background: var(--color-fg);
  color: var(--color-bg);
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--duration-normal) var(--ease-out);
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  border-radius: var(--radius-sm);
}

.toast.toast-error {
  background: var(--color-error);
  color: white;
}

.toast.toast-success {
  background: var(--color-success);
  color: white;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(8px); }
}

/* --- Scroll to Top --- */

.scroll-top {
  position: fixed;
  bottom: var(--sp-lg);
  left: var(--sp-lg);
  z-index: 9998;
  width: 40px;
  height: 40px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  color: var(--color-muted);
  font-size: 1rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: var(--transition-base);
  line-height: 1;
  border-radius: var(--radius-md);
}

.scroll-top.visible {
  display: flex;
  animation: fadeInUp var(--duration-normal) var(--ease-out);
}

.scroll-top:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
  transform: translateY(-2px);
}

/* --- Skeleton Loading --- */

.skeleton {
  background: linear-gradient(90deg, var(--color-border) 25%, var(--color-bg-hover) 50%, var(--color-border) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-xs);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
  width: 100%;
}

.skeleton-text.short {
  width: 40%;
}

.skeleton-text.medium {
  width: 65%;
}

.skeleton-text.long {
  width: 100%;
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--sp-lg);
}

.skeleton-field {
  margin-bottom: var(--sp-sm);
}

.skeleton-field .skeleton-label {
  height: 0.7rem;
  width: 30%;
  margin-bottom: 0.25rem;
}

.skeleton-field .skeleton-value {
  height: 1rem;
  width: 70%;
}

/* --- Animations --- */

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* --- Utilities --- */

.hidden {
  display: none !important;
}

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

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

.mt-md {
  margin-top: var(--sp-md);
}

.mt-lg {
  margin-top: var(--sp-lg);
}

/* --- Panel/Subscription Styles --- */

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-lg);
  flex-wrap: wrap;
  gap: var(--sp-md);
}

.panel-header h1 {
  margin: 0;
}

.panel-header p {
  margin: 0;
  color: var(--color-muted);
}

.subscriptions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: var(--sp-lg);
  margin-top: var(--sp-lg);
}

.subscription-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--sp-lg);
  transition: var(--transition-base);
  display: flex;
  flex-direction: column;
}

.subscription-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--color-brand);
  transform: translateY(-2px);
}

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

.subscription-header h3 {
  margin: 0;
  font-size: 1.125rem;
  color: var(--color-fg);
  font-weight: 600;
}

.subscription-info {
  color: var(--color-muted);
  font-size: 0.9375rem;
  margin-bottom: var(--sp-md);
  flex: 1;
}

.subscription-info p {
  margin: var(--sp-xs) 0;
}

.subscription-info strong {
  color: var(--color-fg);
  font-weight: 500;
}

.subscription-actions {
  display: flex;
  gap: var(--sp-sm);
  flex-wrap: wrap;
  margin-top: var(--sp-md);
}

.panel-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--sp-2xl);
  color: var(--color-muted);
}

.panel-error {
  grid-column: 1 / -1;
  background: var(--color-error-light);
  color: var(--color-error);
  padding: var(--sp-md);
  border-radius: var(--radius-sm);
  text-align: center;
}

/* Keys Panel */

.keys-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: var(--sp-lg);
  margin-top: var(--sp-lg);
}

.key-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--sp-lg);
  transition: var(--transition-base);
}

.key-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-brand);
}

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

.key-header h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--color-fg);
  font-weight: 600;
}

.key-value {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--sp-sm);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  word-break: break-all;
  margin-bottom: var(--sp-sm);
  color: var(--color-fg);
}

.key-meta {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
  color: var(--color-muted);
  font-size: 0.875rem;
}

.key-actions {
  display: flex;
  gap: var(--sp-sm);
  margin-top: var(--sp-md);
}

/* Modals */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn var(--duration-normal) var(--ease-out);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: fadeInUp var(--duration-normal) var(--ease-out);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-lg);
  border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--color-fg);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-muted);
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}

.modal-close:hover {
  color: var(--color-fg);
  background: var(--color-bg-hover);
}

.modal-body {
  padding: var(--sp-lg);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-md);
  padding: var(--sp-lg);
  border-top: 1px solid var(--color-border);
}

/* Info Box */

.info-box {
  background: var(--color-brand-light);
  border: 1px solid var(--color-brand);
  border-radius: var(--radius-sm);
  padding: var(--sp-md);
  margin-top: var(--sp-lg);
  color: var(--color-brand-dark);
  font-size: 0.9375rem;
}

/* Key Display Box */

.key-display-box {
  text-align: center;
  padding: var(--sp-lg);
}

.key-display-box p {
  margin-bottom: var(--sp-md);
}

.key-warning {
  color: var(--color-warning);
  background: var(--color-warning-light);
  padding: var(--sp-md);
  border-radius: var(--radius-sm);
  margin-top: var(--sp-md);
  font-size: 0.9375rem;
}

/* Form Section */

.form-section {
  margin: var(--sp-xl) 0;
  padding: var(--sp-lg);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.form-section h3 {
  margin: 0 0 var(--sp-lg) 0;
  font-size: 1.125rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-lg);
}

/* Tabs */

.tabs {
  display: flex;
  gap: var(--sp-md);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--sp-lg);
}

.tab-btn {
  padding: var(--sp-sm) var(--sp-md);
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--color-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition-base);
  padding-bottom: calc(var(--sp-sm) + 2px);
}

.tab-btn:hover {
  color: var(--color-fg);
}

.tab-btn.active {
  color: var(--color-brand);
  border-bottom-color: var(--color-brand);
}

.tab-content {
  display: none;
  animation: fadeIn var(--duration-normal) var(--ease-out);
}

.tab-content.active {
  display: block;
}

/* Search Results (for autocomplete) */

.search-results {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-top: var(--sp-sm);
  background: var(--color-bg-card);
}

.result-item {
  padding: var(--sp-sm) var(--sp-md);
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  transition: var(--transition-base);
}

.result-item:hover {
  background: var(--color-bg-hover);
}

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

.result-item strong {
  display: block;
  margin-bottom: var(--sp-xs);
  color: var(--color-fg);
}

.result-item small {
  color: var(--color-muted);
}

/* Checkbox */

.checkbox {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-sm);
  cursor: pointer;
  font-size: 0.9375rem;
}

.checkbox input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--color-brand);
}

/* Subscription Form */

.subscription-form {
  max-width: 800px;
  margin: var(--sp-xl) auto;
}

/* Subscription Detail */

.subscription-detail {
  max-width: 800px;
  margin: var(--sp-xl) auto;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-md);
  margin-bottom: var(--sp-xl);
  padding: var(--sp-md);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.meta-item {
  color: var(--color-muted);
  font-size: 0.9375rem;
}

.badge-warning {
  background: var(--color-warning-light);
  color: var(--color-warning);
  border-color: var(--color-warning);
}

.beta-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  background: var(--color-warning-light);
  border-bottom: 1px solid var(--color-warning);
  font-size: 0.8125rem;
  color: var(--color-warning);
  text-align: center;
}

.editable-field {
  display: flex;
  gap: var(--sp-sm);
  flex-wrap: wrap;
}

.editable-field input[type="text"] {
  flex: 1;
  min-width: 200px;
}

.selected-items {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-sm);
  margin-top: var(--sp-sm);
}

.item-tag {
  display: inline-flex;
  align-items: center;
  padding: var(--sp-xs) var(--sp-sm);
  background: var(--color-bg-hover);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  font-size: 0.875rem;
}

.item-tag button {
  background: none;
  border: none;
  margin-left: var(--sp-xs);
  cursor: pointer;
  color: var(--color-muted);
  padding: 0;
  line-height: 1;
}

.item-tag button:hover {
  color: var(--color-error);
}

/* --- Spain Map --- */

/* Leaflet tooltip styling */
.leaflet-tooltip {
  padding: 0.5rem 1rem;
  background: var(--color-fg);
  color: var(--color-bg);
  border-radius: 8px;
  font-size: 0.875rem;
  border: none;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
}

.leaflet-tooltip-top::before {
  border-top-color: var(--color-fg);
}

.map-legend {
  position: absolute;
  bottom: var(--sp-md);
  left: var(--sp-md);
  display: flex;
  gap: var(--sp-md);
  padding: var(--sp-sm) var(--sp-md);
  background: rgba(255,255,255,0.9);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--color-fg);
  backdrop-filter: blur(8px);
}

[data-theme="dark"] .map-legend {
  background: rgba(10,10,11,0.9);
}

.map-legend-item {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
}

.map-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.map-legend-dot.low {
  background: var(--color-border);
}

.map-legend-dot.medium {
  background: var(--color-brand-light);
}

.map-legend-dot.high {
  background: var(--color-brand);
}

/* Countdown Badges */

.countdown {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  padding: var(--sp-xs) var(--sp-sm);
  border-radius: var(--radius-xs);
  border: 1px solid var(--color-border);
}

.countdown-urgent {
  background: var(--color-error-light);
  color: var(--color-error);
  border-color: var(--color-error);
}

.countdown-warning {
  background: var(--color-warning-light);
  color: var(--color-warning);
  border-color: var(--color-warning);
}

.countdown-ok {
  background: var(--color-success-light);
  color: var(--color-success);
  border-color: var(--color-success);
}

[data-theme="dark"] .countdown-urgent {
  background: #450a0a;
  color: #fca5a5;
  border-color: #7f1d1d;
}

[data-theme="dark"] .countdown-warning {
  background: #451a03;
  color: #fcd34d;
  border-color: #78350f;
}

[data-theme="dark"] .countdown-ok {
  background: #052e16;
  color: #86efac;
  border-color: #166534;
}

/* Results Container Layout */
#results-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.results-container {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.card-title a {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 1rem;
  line-height: 1.4;
  font-weight: 600;
}

/* Responsive Design - Mobile (max-width: 768px) */
@media (max-width: 768px) {
  .card-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-xs);
  }

  .card-meta span:first-child {
    white-space: normal;
    overflow: visible;
    min-width: 100%;
  }

  .card-body {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-sm);
  }

  .card-body > * {
    min-width: 100%;
    flex: 1 1 100%;
  }

  .card-body .amount {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--sp-xs) 0;
  }

  .card-body .amount {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-xs);
  }

  .card-title a {
    font-size: 1rem;
    line-height: 1.4;
  }

  .badge {
    font-size: 0.625rem;
    padding: 1px 6px;
  }

  .detail-section h2 {
    font-size: 1rem;
  }

  .card-body .amount {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-xs);
  }
}

/* Very Small Screens (max-width: 480px) */
@media (max-width: 480px) {
  .card-body .amount {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-xs);
  }
}

/* --- Responsive --- */

@media (min-width: 480px) {
  .stats-grid {
    gap: var(--sp-lg);
  }
}

@media (min-width: 600px) and (max-width: 960px) {
  .search-page {
    padding: var(--sp-lg) var(--sp-md);
  }

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

  .result-card {
    padding: var(--sp-md);
  }

  .card-body > * {
    min-width: 100px;
  }

  .card-meta span:first-child {
    min-width: 150px;
  }
}

@media (min-width: 960px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .features-grid {
    grid-template-columns: repeat(3, 1fr);
  }

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

@media (max-width: 960px) {
  .hero-container {
    grid-template-columns: 1fr;
    gap: var(--sp-lg);
  }

  .hero-map {
    order: -1;
    height: 400px;
  }

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

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

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

  .detail-table {
    font-size: 0.75rem;
  }

  .detail-table th,
  .detail-table td {
    padding: var(--sp-xs) var(--sp-sm);
  }
}

@media (max-width: 600px) {
  .container {
    padding: 0 var(--sp-sm);
  }

  .search-page {
    padding: var(--sp-md) var(--sp-sm);
  }

  .search-form {
    padding: var(--sp-md);
    margin-bottom: var(--sp-lg);
  }

  .search-row {
    flex-direction: column;
  }

  .search-row button {
    width: 100%;
  }

  .result-card {
    padding: var(--sp-md);
    margin-bottom: var(--sp-sm);
  }

  .results-header {
    flex-direction: column;
    gap: var(--sp-sm);
    align-items: flex-start;
  }

  .card-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-xs);
  }

  .card-meta span:first-child {
    white-space: normal;
    overflow: visible;
    min-width: 100%;
  }

  .card-body {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-sm);
  }

  .card-body > * {
    min-width: 100%;
    flex: 1 1 100%;
  }

  .card-body .amount {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--sp-xs) 0;
  }

  .hero-title-main {
    font-size: 2.5rem;
  }

  .hero-title-sub {
    font-size: 1.25rem;
  }

  .hero-cta {
    flex-direction: column;
    width: 100%;
  }

  .btn-lg {
    width: 100%;
  }

  .stat-card {
    flex-direction: column;
    text-align: center;
  }

  .stat-icon {
    margin: 0 auto;
  }

  .cookie-banner .container {
    flex-direction: column;
    text-align: center;
  }

  .cookie-buttons {
    width: 100%;
    flex-direction: column;
  }

  .cookie-buttons .btn {
    width: 100%;
  }

  #toast-container {
    left: var(--sp-md);
    right: var(--sp-md);
    max-width: none;
  }

  .scroll-top {
    bottom: var(--sp-md);
    left: var(--sp-md);
  }

  table {
    font-size: 0.8rem;
  }

  table th,
  table td {
    padding: var(--sp-sm);
  }

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

  .section-header {
    flex-direction: column;
    gap: var(--sp-sm);
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .hero-title-main {
    font-size: 2rem;
  }

  .hero-title-sub {
    font-size: 1.125rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .hero-map {
    height: 300px;
  }

  .form-page {
    padding: var(--sp-md);
  }

  .form-page h1 {
    font-size: 1.5rem;
  }

  .detail-header h1 {
    font-size: 1.25rem;
  }

  .detail-meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .detail-section {
    padding: var(--sp-md);
  }

  .detail-section h2 {
    font-size: 1rem;
  }

  .card-body .amount {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-xs);
  }

  .card-title a {
    font-size: 1rem;
    line-height: 1.4;
  }

  .badge {
    font-size: 0.625rem;
    padding: 1px 6px;
  }
}

.cpv-tree {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  max-height: 400px;
  overflow-y: auto;
  background: var(--color-bg-card);
}

.cpv-tree-search {
  width: 100%;
  padding: var(--sp-sm) var(--sp-md);
  border: none;
  border-bottom: 1px solid var(--color-border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 0.875rem;
  background: var(--color-bg-card);
  color: var(--color-fg);
  outline: none;
}

.cpv-tree-search:focus {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px var(--color-brand-alpha);
}

.cpv-tree-node {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: 2px 4px;
  transition: background var(--duration-fast);
  border-radius: var(--radius-xs);
}

.cpv-tree-node:hover {
  background: var(--color-bg-hover);
}

.cpv-tree-toggle {
  cursor: pointer;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-muted);
  font-size: 0.75rem;
  user-select: none;
  flex-shrink: 0;
  margin-top: 2px;
}

.cpv-tree-toggle:hover {
  color: var(--color-fg);
}

.cpv-tree-checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-xs);
  flex: 1;
  cursor: pointer;
  padding: 2px 0;
  font-size: 0.875rem;
}

.cpv-tree-checkbox input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--color-brand);
  flex-shrink: 0;
  margin-top: 2px;
}

.cpv-code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-brand);
  font-weight: 500;
  flex-shrink: 0;
  min-width: 70px;
}

.cpv-label {
  color: var(--color-fg);
  line-height: 1.3;
  word-break: break-word;
}

.cpv-tree-children {
  overflow: hidden;
  transition: max-height 0.2s ease;
}