@media (max-width: 768px) {
  body {
    overflow-x: hidden !important;
  }
  .main-container,
  .header-inner,
  .query-section,
  .results,
  .modal-content,
  .config-panel,
  .card {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
  
  /* Header Mobile Styles */
  .header {
    padding: 20px 16px !important;
  }
  
  .status-container {
    flex-direction: column !important;
    gap: 16px !important;
    align-items: stretch !important;
  }
  
  .brand-section {
    order: 1;
  }
  
  .logo-brand-container {
    gap: 12px !important;
  }
  
  .logo-brand-container img {
    width: 50px !important;
    height: 50px !important;
  }
  
  .title {
    font-size: 24px !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
    line-height: 1.2 !important;
  }
  
  .title span {
    font-size: 14px !important;
  }
  
  .subtitle {
    font-size: 13px !important;
    line-height: 1.3 !important;
  }
  
  .status-indicator {
    order: 2;
    align-self: flex-start !important;
    padding: 8px 16px !important;
    font-size: 12px !important;
  }

  /* Quick Links Mobile Styles */
  .quick-links {
    order: 3;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
    margin-top: 8px !important;
  }
  
  .quick-links a {
    justify-content: center !important;
    width: 100% !important;
    font-size: 11px !important;
    padding: 8px 12px !important;
  }
  
  .config-button {
    margin-bottom: 16px !important;
    font-size: 13px !important;
    padding: 12px 16px !important;
  }
  
  /* Core Configuration specific styles */
  .grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  
  /* Fix overflow issues in configuration modal */
  .config-panel > div {
    overflow-x: hidden !important;
  }
  
  .config-panel .grid > div {
    max-width: 100% !important;
    overflow-x: hidden !important;
  }
  .modal-content {
    padding: 0 !important;
  }
  
  .modal-body {
    padding: 16px 12px !important;
    overflow-x: hidden !important;
  }
  
  .config-panel {
    padding: 16px 12px !important;
  }
  .tabs,
  .input-group,
  .config-actions {
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
  }
  .input,
  .textarea,
  .select,
  .button,
  .config-button {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 44px !important;
    font-size: 15px !important;
    box-sizing: border-box !important;
  }
  
  .textarea {
    max-width: 100% !important;
    overflow-x: hidden !important;
    word-wrap: break-word !important;
    resize: vertical !important;
  }
  .modal-header {
    padding: 12px 8px !important;
    min-height: 48px !important;
  }
  .modal-close,
  .error-close {
    min-width: 44px !important;
    min-height: 44px !important;
    font-size: 24px !important;
  }
  .modal-overlay {
    align-items: flex-start !important;
    padding: 0 !important;
  }
  .modal-content {
    min-width: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    margin: 0 !important;
    border-radius: 0 !important;
  }
  .tabs {
    flex-wrap: wrap !important;
    gap: 2px !important;
    margin-bottom: 10px !important;
  }
  .card {
    margin-bottom: 10px !important;
    padding: 12px !important;
  }
  .results h3, .results h4 {
    font-size: 1rem !important;
  }
  .results .card, .results .metricsCard {
    font-size: 1rem !important;
    padding: 12px !important;
  }
  .results pre, .results .ai-response {
    font-size: 13px !important;
    padding: 12px !important;
    border-radius: 8px !important;
  }
  .results summary {
    font-size: 14px !important;
  }
  .results a {
    font-size: 12px !important;
    word-break: break-all;
  }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
  .header {
    padding: 16px 12px !important;
  }
  
  .logo-brand-container {
    gap: 8px !important;
  }
  
  .logo-brand-container img {
    width: 40px !important;
    height: 40px !important;
  }
  
  .title {
    font-size: 20px !important;
  }
  
  .title span {
    font-size: 12px !important;
  }
  
  .subtitle {
    font-size: 12px !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  
  .status-indicator {
    padding: 6px 12px !important;
    font-size: 11px !important;
  }
  
  .config-button {
    font-size: 12px !important;
    padding: 10px 14px !important;
    text-align: center !important;
  }
  
  /* Extra tight constraints for very small screens */
  .modal-body {
    padding: 12px 8px !important;
  }
  
  .config-panel {
    padding: 12px 8px !important;
  }
  
  .textarea {
    font-size: 13px !important;
    padding: 12px !important;
    min-height: 100px !important;
    max-height: 150px !important;
  }
  
  /* Ensure no horizontal overflow */
  * {
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }
}
